Ive got a simple menu that upon hover of each item, plays a movie clip, then on mouse_out it plays the movie clip in reverse. What I'm trying to do is to have a third state (active) that is shown upon clicking. I'm thinking I need to do something along the lines of:
When clicked, gotoAndStop(5) //Five being the location of my active frame Also remove the event listener that triggers the function to play the movie in reverse. Then when another menu item is clicked, re-add the event listener to the previous menu item so it's not stuck 'active'
I can't quite figure out how to do this though. My code is as follows:
// IMPORTS
import fl.transitions.*;
import fl.transitions.Tween;
import fl.transitions.easing.*;
import flash.external.ExternalInterface;
// EVENT LISTENERS
//arrow
mcArrow.addEventListener(MouseEvent.MOUSE_OVER,mover);
mcArrow.addEventListener(MouseEvent.MOUSE_OUT,mout);
//dots
mcDots.addEventListener(MouseEvent.MOUSE_OVER,mover);
mcDots.addEventListener(MouseEvent.MOUSE_OUT,mout);
//music
mcMusic.addEventListener(MouseEvent.MOUSE_OVER,mover);
mcMusic.addEventListener(MouseEvent.MOUSE_OUT,mout);
//home
mcHome.addEventListener(MouseEvent.MOUSE_OVER,mover);
mcHome.addEventListener(MouseEvent.MOUSE_OUT,mout);
//padlock
mcPadlock.addEventListener(MouseEvent.MOUSE_OVER,mover);
mcPadlock.addEventListener(MouseEvent.MOUSE_OUT,mout);
// FUNCTIONS
function mover(e:MouseEvent):void {
stopPlayReverse(e.currentTarget as MovieClip);
e.currentTarget.play();
//var fadeIn:Tween = new Tween(mcToolTip, "alpha", Strong.easeOut, 0, 1, 0.5, true);
}
function mout(e:MouseEvent):void {
var mc:MovieClip = e.currentTarget as MovieClip;
if (mc !== null) {
mc.addEventListener(Event.ENTER_FRAME, playReverse, false, 0, true);
}
//var fadeOut:Tween = new Tween(mcToolTip, "alpha", Strong.easeOut, 1, 0, 0.5, true);
}
function playReverse(e:Event):void {
var mc:MovieClip = e.currentTarget as MovieClip;
if (mc.currentFrame == 1) {
stopPlayReverse(mc);
} else {
mc.prevFrame();
}
}
function stopPlayReverse(mc:MovieClip):void {
if ((mc!==null) && mc.hasEventListener(Event.ENTER_FRAME)) {
mc.removeEventListener(Event.ENTER_FRAME, playReverse);
}
}