I'm trying to use addFrameScript()
on a SWF animation I have loaded but am running into a few problems. Here's what works right now:
public function project() {
var loader:Loader = new Loader();
loader.load(new URLRequest("animation.swf"));
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, animLoadComplete, false, 0, true);
}
private function animLoadComplete(e:Event):void {
anim = e.target.content as MovieClip;
addChild(anim);
//anim.addFrameScript(anim.totalFrames - 1, animEnd);
}
private function animEnd():void {
trace("animEnd");
}
Like this, the animation plays fin and just loops over and over again.
The trouble seems to be that the animation runs regardless of using stop()
, play()
or any animation function. A trace(anim.totalFrames)
also shows that my animation is 2 frames rather than 23 (which it is).
When I un-comment anim.addFrameScript(anim.totalFrames - 1, animEnd);
the frame script appears to be called every frame and the animation ceases to play and is instead replaced by the flash "loading dots" where it should appear.
I suppose my question is twofold. Am I loading in my animation properly and why does a framescript cause my animation to disappear?