dnainby 0 Posted December 12, 2007 Report Share Posted December 12, 2007 i'm currently using the createMovieClip() function. I have dynamically created Movie Clip and loaded a file into it and it works fine. All i need to do is control the Movie Clip from a seperate button to say, stop(), gotoAndStop(), play() etc etc...The code i have used is below. I can't seem to control the Movie Clip from the button at the moment and i don't want to have to put the button function inside the loadListener (it works in there!).Any suggestions would be greatly recieved. MTIA //init variablesmovieToLoad = "Media/SWF/anim.swf";createMovieClip();step_but.onRelease=function() { trace("button pressed"); contentHolder.stop();};//CREATE MOVIE CLIP TO HOLD IMAGEfunction createMovieClip(){ var sectionHolder = "sectionHolder"; this.createEmptyMovieClip(sectionHolder, this.getNextHighestDepth()); var loadListener:Object = new Object(); loadListener.onLoadComplete = function(contentHolder:MovieClip) { trace("movie loaded"); }; var contentLoader:MovieClipLoader = new MovieClipLoader(); contentLoader.addListener(loadListener); contentLoader.loadClip(movieToLoad, sectionHolder);} Quote Link to post Share on other sites
justsomeguy 1,135 Posted December 12, 2007 Report Share Posted December 12, 2007 The reason it works inside the loadListener.onLoadComplete function is because that is the only place where the contentHolder variable exists, once that function ends the variable name contentHolder no longer refers to anything. The movie still exists, it just doesn't have a name. You can create a contentHolder variable outside that function then just have the function assign a reference to the movie to the variable. So outside of the createMovieClip function you would have this:var contentHolder = new MovieClip();Then the event handler would do this: loadListener.onLoadComplete = function(mc:MovieClip) { trace("movie loaded"); contentHolder = mc; }; Quote Link to post Share on other sites
dnainby 0 Posted December 14, 2007 Author Report Share Posted December 14, 2007 Yep, cheers, that works a treat - sometimes you just can't see the wood for the trees! Quote Link to post Share on other sites
Synook 47 Posted December 15, 2007 Report Share Posted December 15, 2007 Thought it was "sometimes you can't see the trees for the wood" Quote Link to post Share on other sites
SpOrTsDuDe.Reese 1 Posted December 17, 2007 Report Share Posted December 17, 2007 Yea that's what I thought...lmao Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.