Controlling the timeline of an swf loaded in with loadMovie


#1

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?


#2

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 :smiley:


#3

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…


#4

Yvo, this is the code for AS2:

btn2.onPress = function() {
	holder.gotoAndPlay(2);
};

#5
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


#6
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 :stuck_out_tongue: 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.


#7
Yvo, this is the code for AS2:
 btn2.onPress = function() { holder.gotoAndPlay(2); }; 

sorry digital science thats incorrect MSFX is correct

YEAH!! 8)

but no lol :stuck_out_tongue:

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… :smiley:


#8

Thanks very much for the effort guys!!! I’ll give it a try.


#9

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


#10

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. :wink:


#11

Well if you knew, why use loadMovie, get into trouble and ask a question?

lol… Just wondering…


#12

Messing with a very old file :wink: