I am trying to animate a hexagon spinning like a wheel indefinitely:
function rotateCW(e:TweenEvent = null):void{
var hexRot:Tween = new Tween(this, "rotationZ", None.easeNone, 0, 360, 2, true);
hexRot.addEventListener(TweenEvent.MOTION_FINISH, rotateCW);
}
For some strange reason the animation stops after a random amount of repetitions. It varies anything from between 2 and 600 times before it stops.
I’ve got a whole bunch of different events firing all over the place in my application, is it possible that this might cause the MOTION_FINISH event to either not fire or not get caught?
Thanks!
First of all you should define
hexRotand listen to its MOTION_FINISH outisde of your function. By doing like you do, every hexRot stays in memory since it has a listener attached to it.This may not solve your problem but it will be a cleaner way to write things and you will be less vulnerable to strange behaviors.