Using Flash 8 and started with Kirupa’s sliding menu example. The difference with my movie is I am making a menu that slids in and out on mouse over and mouse out on said movie.
The trouble I am having is when I mouse over and out quickly a few times my movie seems to get stuck opening and closing on it’s own. I have included all the code below to see if anyone sees something simple. All I am trying to do, as in K’s example, is move the move to a spot then move it back. I tested the idea using the movie its self as the action event as the problem by making a button that does the same thing but I got the same result.
I made one other slight change to K’s code by essentially hard coding the “out” and “in” states of my menu.
Anyway, there is my code.
var currentPosition:Number = _root.FlyOut._x;
var startFlag:Boolean = false;
var finalDestination:Number ;
menuSlide = function (input:MovieClip) {
if (_root.startFlag == false) {
startFlag = true;
var distanceMoved:Number = 0;
var distanceToMove:Number = Math.abs(_root.finalDestination-currentPosition);
var finalSpeed:Number = .3;
var currentSpeed:Number = 0;
var dir:Number = 1;
if (currentPosition<=_root.finalDestination) {
dir = 1;
} else if (currentPosition>_root.finalDestination) {
dir = -1;
}
this.onEnterFrame = function() {
trace ("in onEnterFrame");
currentSpeed = Math.round((distanceToMove-distanceMoved+1)*finalSpeed);
distanceMoved += currentSpeed;
_root.FlyOut._x += dir*currentSpeed;
trace("X = "+_root.FlyOut._x);
if (Math.abs(distanceMoved-distanceToMove)<=1) {
trace("** BEGINING CLEAN UP");
trace("FlyOut._x = " + FlyOut._x);
if (dir == 1 ) {
_root.currentPosition = 30;
}
else {
_root.currentPosition = -138;
}
startFlag = false;
delete this.onEnterFrame;
trace ("** DONE CLEANING UP **");
}
};
}
};
FlyOut.onRollOver = function() {
finalDestination = 30;
menuSlide(_root.FlyOut);
};
FlyOut.onRollOut = function() {
finalDestination = -138;
menuSlide(_root.FlyOut);
};