- Bought between 1 and 9 items
- Exclusive Author
- Has been a member for 6-7 years
- Netherlands
- Referred between 50 and 99 users
- Sold between 1 000 and 5 000 dollars
Hi guys, this might have been asked and answered before, but don’t know exactly what to look for in the forum. I want to know if it is possible to control the timeline of an external swf loaded in with loadMovie.
Example: Let’s say I have a main file in which I have 2 button mc’s with instance names btn1 and btn2. I have a holder mc on which I can load my swf. Let’s call that external.swf. This external swf has a stop command in frame 1 and in that last frame of its timeline.
When I press btn1 I want it to load in the external.swf onto the holder just using the loadMovie command. Nothing difficult here of course. When it is loaded in it stays on frame 1 due to the stop command in frame 1. I want the external.swf to start going to frame 2 (and thus start playing until the last frame) when I press btn2. Is this possible? And if so, how?
- Attended a Community Meetup
- Community Moderator
- Has been a member for 5-6 years
- United Kingdom
- Contributed a Tutorial to a Tuts+ Site
- Won a Competition
- Contributed a Blog Post
- Beta Tester
- Bought between 50 and 99 items
I know this is do-able as I do it all the time but in AS3 , not AS2 …
Once you have stored it to your holder variable maybe try this
holder.externalSWF.gotoAndPlay(2);
In AS3 i’d use:
// store loaded content swf = MovieClip(e.currentTarget.content) swf.gotoAndPlay(2);
easy 
- Attended a Community Meetup
- Community Moderator
- Has been a member for 5-6 years
- United Kingdom
- Contributed a Tutorial to a Tuts+ Site
- Won a Competition
- Contributed a Blog Post
- Beta Tester
- Bought between 50 and 99 items
come to think of it there was a file not that long ago that allowed to go scroll through the frames of a loaded swf, maybe have a quick search for that, within the last week or so I think…
- Sold between 250 000 and 1 000 000 dollars
- Has been a member for 6-7 years
- Author had a File in an Envato Bundle
- Most Wanted Bounty Winner
- Interviewed on the Envato Notes blog
- Author was Featured
- Item was Featured
- South Africa
Yvo, this is the code for AS2 :
btn2.onPress = function() {
holder.gotoAndPlay(2);
};
Yvo, this is the code for AS2 : btn2.onPress = function() { holder.gotoAndPlay(2); };
sorry digital science thats incorrect MSFX is correct
so it wil be like
yourbutton.onPress = function() { _root.yourholderinmainmovie.yourexternalswffile.gotoAndplay(2); }
thanks
- Sold between 250 000 and 1 000 000 dollars
- Has been a member for 6-7 years
- Author had a File in an Envato Bundle
- Most Wanted Bounty Winner
- Interviewed on the Envato Notes blog
- Author was Featured
- Item was Featured
- South Africa
Yvo, this is the code for AS2 :btn2.onPress = function() { holder.gotoAndPlay(2); };sorry digital science thats incorrect MSFX is correct
so it wil be like
yourbutton.onPress = function() { _root.yourholderinmainmovie.yourexternalswffile.gotoAndplay(2); }
thanks
wrong
when you load a swf into a holder movieclip, the name of the swf root is the holder instance name. In your code – how exactly do you get the instance name of yourexternalswffile ?? Because when u load a swf you can only identify it by the level or movieclip it’s loaded into.
- Attended a Community Meetup
- Community Moderator
- Has been a member for 5-6 years
- United Kingdom
- Contributed a Tutorial to a Tuts+ Site
- Won a Competition
- Contributed a Blog Post
- Beta Tester
- Bought between 50 and 99 items
Yvo, this is the code for AS2 :sorry digital science thats incorrect MSFX is correctbtn2.onPress = function() { holder.gotoAndPlay(2); };
YEAH !! 
but no lol 
DS is right, when you load an external SWF into Flash as it is actually an Instance of the Timeline, and therefore you cannot give it a name…
This gave me an initial headache in AS3 but then I worked it out…
var swf:MovieClip; var swfHolder:MovieClip; // once swf has loaded, in your Event.COMPLETE function swfHolder = MovieClip(e.currentTarget.content); swf = new MovieClip(); swf.addChild(swfHolder); swf.name = "whateverNameHere";
If I had tried to name the swfHolder instance I would get a compiler error or run time, cant remember which… 
- Bought between 1 and 9 items
- Exclusive Author
- Has been a member for 6-7 years
- Netherlands
- Referred between 50 and 99 users
- Sold between 1 000 and 5 000 dollars
Thanks very much for the effort guys!!! I’ll give it a try.
- Bought between 1 and 9 items
- Exclusive Author
- Has been a member for 5-6 years
- Item was Featured
- Netherlands
- Referred between 10 and 49 users
- Repeatedly Helped protect Envato Marketplaces against copyright violations
- Sold between 10 000 and 50 000 dollars
First off, don’t use the loadMovie command. It sucks.
use something like this:
//** //Function to load a clip or picture //** function theLoader(loadUrl, loadHold) { //flip our loadStat loadStat = true; //create a new loader object var mcLoader:MovieClipLoader = new MovieClipLoader(); //create a new listener object var mcListener:Object = new Object(); //function to give a visual representation of the loading progress //on load init mcListener.onLoadInit = function(target:MovieClip) { //flip the load track variable loadStat = false; //if there is a next function, trigger it nextFunc(); //clear the trigger nextFunc = nada; }; //add a movieclip loader mcLoader.addListener(mcListener); }
//load the clip
mcLoader.loadClip(loadUrl, loadHold);
What you would do is create a holder (which you did), have an external file (which you have) and simply call the function
theLoader(“myswf.swf”, holderMc);
How does this help? Well NOT .. But it gives you a. more control over loading (maybe check the loadStat) b. an option to directly work on the clip once loaded, by adding instructions at the onLoadInit. There you could state, loadHold.gotoAndStop(1); or you could trigger a function like myFunction(loadHold) and the instance name gets passed without any problems.
If you keep running into trouble, add trace(loadHold._name) to the onLoadInit and it will display the name of the holder (DS is correct)..
you should basicly only use loadMovie when you don’t want to control, modify or whatever.
good luck
- Bought between 1 and 9 items
- Exclusive Author
- Has been a member for 6-7 years
- Netherlands
- Referred between 50 and 99 users
- Sold between 1 000 and 5 000 dollars
I know my question might sound like I’m a beginner, but I’m not. I was just wondering if it is possible, cause I’m trying something. I used loadMovie in my file, cause I did not need to have control over the loading. Just a very simple load in of an swf.
When making a gallery or something like that, I always use the movieClipLoader class, so I can use preloaders for images. Cheers for the help Fonz, but I was already aware of loading in images this way. 
