I think I’m just missing something simple.
Explanation of the Code
My code is contained in a movie clip that plays an animation on roll over and reverses the animation on roll off. The reverse uses a timer that backs up a frame on the each time event. It works for the most part.
Problem
I tried to use watchTimer.stop(); to end the timer. But the eventListener that tracks timer events keeps triggering which I don’t want.
var watchTimer:Timer = new Timer(30);
this.addEventListener(MouseEvent.MOUSE_OVER, foldUp);
this.addEventListener(MouseEvent.MOUSE_OUT, foldDown);
//Play Animation on MOUSE_OVER
function foldUp(evt:MouseEvent):void {
if (this.currentFrame != 11) {
gotoAndPlay(currentFrame + 1);
}
}
//Start Timer on Mouse Off
function foldDown (evt:MouseEvent):void {
watchTimer.start();
}
//Play Reverse Animation on Timer Event
watchTimer.addEventListener(TimerEvent.TIMER, onTimer);
function onTimer(evt:TimerEvent):void {
if (currentFrame != 1){
gotoAndStop(currentFrame - 1)
}
else {
//End Timer when Animation is completed
watchTimer.stop();
}
}