Copy link to clipboard
Copied
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");
}
}
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
Hello again Ned. I've ditched the A1/2 files. Strictly working with external AS3 files now.
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
Does the loaded SWF have frames? I mean if it's strictly AS controlled, then testing for totalFrames isn't going to work.
Copy link to clipboard
Copied
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);
}
}
Find more inspiration, events, and resources on the new Adobe Community
Explore Now