Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

New Here ,
Jan 17, 2014 Jan 17, 2014

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.

TOPICS
ActionScript
541
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Jan 17, 2014 Jan 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.

Translate
LEGEND ,
Jan 17, 2014 Jan 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 17, 2014 Jan 17, 2014

Thanks for suggest,

Can you suggest any idea for the same.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 17, 2014 Jan 17, 2014
LATEST

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

          

        }   

    }

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines