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

How to detect external SWF has stopped not using totalFrames

New Here ,
Mar 04, 2015 Mar 04, 2015

Trying to find a way to detect when an externally loaded SWF has stopped. Using "totalFrames" like the example below doesn't work for what I'm trying to accomplish.

I need something that simply listens and detects when the clip has stopped. Editing the external SWF is not an option. Thanks in advance for any insight.

function onfrm( evnt: Event 😞 void
{
if (newMC.currentFrame == newMC.totalFrames )
{
newMC.removeEventListener( Event.ENTER_FRAME, onfrm);
trace("End of banner");
}
}

TOPICS
ActionScript
363
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
LEGEND ,
Mar 04, 2015 Mar 04, 2015

If it is still an AS1/2 file you can't interact with it.  Have you considered working in AS1/2 instead so that you can interact with the loaded files?

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 ,
Mar 04, 2015 Mar 04, 2015

Hello again Ned. I've ditched the A1/2 files. Strictly working with external AS3 files now.

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
LEGEND ,
Mar 04, 2015 Mar 04, 2015

Too bad editing the swf is out because the proper way of doing this is to have the loaded file dispatch an event for which your main file assigns a listener when the file is loaded.  Beyond that, your only option as far as I can see it is to monitor the currentFrame vs totalFrames.  What happens with it that you don't feel works as desired?

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
Enthusiast ,
Mar 04, 2015 Mar 04, 2015

Does the loaded SWF have frames? I mean if it's strictly AS controlled, then testing for totalFrames isn't going to work.

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
Enthusiast ,
Mar 04, 2015 Mar 04, 2015
LATEST

Just did a small test, and at least with loading a swf that has a timeline the totalFrames option works fine:

var m:MovieClip;

var a:Loader = new Loader();

a.contentLoaderInfo.addEventListener(Event.COMPLETE, done);

a.load(new URLRequest("anim.swf"));

function done(e:Event):void

{

  m = MovieClip(a.content);

  m.addEventListener(Event.ENTER_FRAME, chek);

  addChild(m);

}

function chek(e:Event):void

{

  if(m.currentFrame == m.totalFrames){

  trace("done");

  m.removeEventListener(Event.ENTER_FRAME, chek);

  }

}

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