dnainby Posted December 12, 2007 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);} Link to comment Share on other sites More sharing options...
justsomeguy Posted December 12, 2007 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; }; Link to comment Share on other sites More sharing options...
dnainby Posted December 14, 2007 Author Share Posted December 14, 2007 Yep, cheers, that works a treat - sometimes you just can't see the wood for the trees! Link to comment Share on other sites More sharing options...
Synook Posted December 15, 2007 Share Posted December 15, 2007 Thought it was "sometimes you can't see the trees for the wood" Link to comment Share on other sites More sharing options...
SpOrTsDuDe.Reese Posted December 17, 2007 Share Posted December 17, 2007 Yea that's what I thought...lmao Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.