I’ve been battling this one for a while. I was originally using a bunch of Tweens to animate various sprites. My tweens were dying too soon and I read that if you simply stuck the tweens in a dictionary that garbage collection would no longer remove the tween before the tween was completed.
I ended up getting rid of the tweens altogether and resorted to using listeners on Event.ENTER_FRAME, but I seem to be having the same problem. The problem is intermittent but sometimes my animations will stop too early and indeed my ENTER_FRAME functions are stopping before I would like them to.
Perhaps what I am doing is too much (Animating size and color on 72 rectangle sprites while simultaneously drawing and rasterizing a pixelated ellipse animation), but maybe I am doing something wrong, I’m just getting back into Flash. Here is a snippet showing my ENTER_FRAME listening:
public function animate(duration:Number) {
var date:Date = new Date();
animateStartTime = date.getTime();
animateDuration = duration * 1000;
this.addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function onEnterFrame(event:Event) {
var date:Date = new Date();
var currentTime:Number = date.getTime() - animateStartTime;
var position = Strong.easeOut(currentTime, 0, 1, animateDuration);
if (position >= 1) {
this.graphics.clear();
this.removeEventListener(Event.ENTER_FRAME, onEnterFrame);
}
render(position);
}