Copy link to clipboard
Copied
I have total 4 exter swf naming 1.swf, 2.swf. 3.swf, 4..swf
able to load 1st swf, want to load all the swf in sequance.
var swfNumber:int=1;
var totalSwf:int=4;
var myLoader:Loader = new Loader();
var myRequest:URLRequest = new URLRequest("swf/"+swfNumber+".swf");
myLoader.load(myRequest);
addChild(myLoader);
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,loaded);
function loaded(event:Event){
trace("Loaded");
var extSwf = myLoader.content as MovieClip;
trace (extSwf.totalFrames)
trace (extSwf.currentFrame)
if (extSwf.currentFrame==2) {
trace("a")
}
}
Here I am not able to trace a on where I am checking 2nd frame however able to trace a when I checking on 1st frame using below mentioned code
if (extSwf.currentFrame==2) {
trace("a")
}
Any Idea.
Your loaded function will execute only one time immediately after the file as loaded, before it starts playing. Chances are when it does the currentFrame will be frame 1 since the file has yet to do anything. You would need to continuously check for frame 2 if you want to catch when it reaches there.
Copy link to clipboard
Copied
Your loaded function will execute only one time immediately after the file as loaded, before it starts playing. Chances are when it does the currentFrame will be frame 1 since the file has yet to do anything. You would need to continuously check for frame 2 if you want to catch when it reaches there.
Copy link to clipboard
Copied
Thanks for suggest,
Can you suggest any idea for the same.
Copy link to clipboard
Copied
Below is the correct code..
I have done it.....
var swfNumber:int=1;
var totalSwf:int=4;
var myLoader:Loader = new Loader();
var myRequest:URLRequest = new URLRequest("swf/"+swfNumber+".swf");
myLoader.load(myRequest);
stage.addChild(myLoader);
myLoader.contentLoaderInfo.addEventListener(Event.INIT , loaded)
function loaded(evt:Event):void
{
var extSwf = myLoader.content as MovieClip;
trace (extSwf.currentFrame)
trace (extSwf.totalFrames)
trace("Loaded")
extSwf.addEventListener(Event.ENTER_FRAME, onFrame);
function onFrame(e:Event):void
{
if (extSwf.currentFrame == 2) //you can take any frame number where you want to trace I have used it to check last frame which totalFrames
{
trace("a")
}
}
}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now