SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Dec 2008
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Attaching movies and dynamically calling them

    Right, to say I'm getting a little frustrated with this is an understatement.

    Basically, I'm using attachMovie to load in a linked movieclip from the library, I then need to dynamically (depending on which part of the movieclip is clicked) load in another linked movieclip into the mc originally loaded.....if that makes sense.... Loading the first movieclip is working perfectly, but I'm having real trouble loading in the second into the original.

    Code:
    loadHolder = function(wBag) {
    	_root.dw_mc.pcb_mc._visible = false;
    	_global.cBag = wBag;
    	unloadMovie("holder_mc");
    	_root.dw_mc.attachMovie(wBag, "holder_mc", 1, {_x: 200, _y: 200});
    }
    
    loadFabric = function(selectedBit, fabric) {
    	var selectedMc:Object = new Object();
    	selectedMc = _root.dw_mc.holder_mc[selectedBit];
    	trace (selectedMc);
    	unloadMovie(selectedMc);
    	selectedMc.attachMovie(fabric, "fabric_mc", 1, {_x: 0, _y: 0});
    }
    
    _root.fb_mc.red_mc.onRelease = function() {
    	selectedBit = "bottom_mc"; //temp until part selection works
    	loadFabric(selectedBit, "exf_red");
    }
    loadHolder is the function that is working, and is called when the frame runs, loadFabric is the one with issues. It unloads the movie perfectly, but refuses to load the linked movieclip (currently just a red square) in.

    Hope someone can spot the no doubt stupid mistake I've made, thanks all!

  2. #2
    SitePoint Evangelist ferrari_chris's Avatar
    Join Date
    Mar 2008
    Location
    NP, New Zealand
    Posts
    576
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think your problem lies here:

    Code Actionscript:
    unloadMovie(selectedMc);
    selectedMc.attachMovie(fabric, "fabric_mc", 1, {_x: 0, _y: 0});

    unloadMovie(selectedMc) will remove that MovieClip. You can't then attach another MovieClip to it as it doesn't exist any more... Move your trace() to under the unloadMove() and see if it is undefined. If it is, then Actionscript can't attach another MovieClip to it.

  3. #3
    SitePoint Member
    Join Date
    Dec 2008
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ahhh ok, so do I need to unload the fabric_mc movieclip instead? This is irrelevant the first time a pattern/colour is selected, but will be used when someone is swapping between different options.

    Massive thanks for the help, I thought it might be something silly!

  4. #4
    SitePoint Evangelist ferrari_chris's Avatar
    Join Date
    Mar 2008
    Location
    NP, New Zealand
    Posts
    576
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by thebluefox View Post
    Ahhh ok, so do I need to unload the fabric_mc movieclip instead? ...
    I don't know sorry, as I don't understand your context enough.

    But the two lines I showed you earlier will fix your initial problem.

    Sounds like you might be on your way now. Good luck!

  5. #5
    SitePoint Member
    Join Date
    Dec 2008
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you, now working perfectly


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •