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?
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…
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.
sorry digital science thats incorrect MSFX is correct
YEAH!! 8)
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…
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.
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.