Stopping reverse animation
mentalcase129 Aug 8, 2014 2:50 PMI have 2 buttons. One has a rollover event to play a movieclip and an out event to then stop the movieclip at the exact spot it was at when the mouse was moved off the button. The button is supposed to play the same movie clip in reverse and then stop when the mouse is moved.
I have the first button working perfectly. The animation plays when the mouse is rolledover and the animation stops in its tracks when the mouse is rolled off.
The second button is giving me grief though. It took a while but I was eventually able to find some code to make the movieclip play in reverse like I wanted but the out even doesn't work. Once the reverse animation is started it there's not stopping it until it gets to the first frame of the movieclip again. Can anybody see from my code what needs to be done to make the reverse play stop in its tracks when the mouse moves off the button?
Here's my code:
gallery.stop();
/* Mouse Over Event
Mousing over the symbol instance executes a function in which you can add your own custom code.
Instructions:
1. Add your custom code on a new line after the line that says "// Start your custom code" below.
The code will execute when the symbol instance is moused over.
*/
right.addEventListener(MouseEvent.MOUSE_OVER, fl_MouseOverHandler);
function fl_MouseOverHandler(event:MouseEvent):void
{
gallery.play();
}
/* Mouse Out Event
Mousing out of the symbol instance executes a function in which you can add your own custom code.
Instructions:
1. Add your custom code on a new line after the line that says "// Start your custom code" below.
The code will execute when the symbol instance is moused out of.
*/
right.addEventListener(MouseEvent.MOUSE_OUT, fl_MouseOutHandler);
function fl_MouseOutHandler(event:MouseEvent):void
{
gallery.stop();
}
/* Mouse Over Event
Mousing over the symbol instance executes a function in which you can add your own custom code.
Instructions:
1. Add your custom code on a new line after the line that says "// Start your custom code" below.
The code will execute when the symbol instance is moused over.
*/
left.addEventListener(MouseEvent.MOUSE_OVER, fl_MouseOverHandler_2);
function fl_MouseOverHandler_2(event:MouseEvent):void
{
this.addEventListener(Event.ENTER_FRAME, playReverse, false, 0, true);
}
function playReverse(e:Event):void {
if (gallery.currentFrame == 1) {
stopPlayReverse();
} else {
gallery.prevFrame();
}
}
function stopPlayReverse():void {
if (this.hasEventListener(Event.ENTER_FRAME)) {
this.removeEventListener(Event.ENTER_FRAME, playReverse);
}
}
/* Mouse Out Event
Mousing out of the symbol instance executes a function in which you can add your own custom code.
Instructions:
1. Add your custom code on a new line after the line that says "// Start your custom code" below.
The code will execute when the symbol instance is moused out of.
*/
left.addEventListener(MouseEvent.MOUSE_OUT, fl_MouseOutHandler_3);
function fl_MouseOutHandler_3(event:MouseEvent):void
{
stop();
}


