Skip to main content
Participant
January 17, 2014
Answered

Loading External SWF into Movieclip on stage but enable to trace currentFrame

  • January 17, 2014
  • 1 reply
  • 588 views

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.

This topic has been closed for replies.
Correct answer Ned Murphy

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.

1 reply

Ned Murphy
Ned MurphyCorrect answer
Legend
January 17, 2014

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.

Participant
January 17, 2014

Thanks for suggest,

Can you suggest any idea for the same.

Participant
January 17, 2014

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")

          

        }   

    }

}