# Sliding Menu troubles - Help needed

**URL:** <https://forum.kirupa.com/t/sliding-menu-troubles-help-needed/222776>\
**Category:** flash\
**Created:** [April 16, 2007, 9:38pm UTC](https://forum.kirupa.com/t/sliding-menu-troubles-help-needed/222776 "2007-04-16T21:38:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rrobbins](https://avatars.discourse-cdn.com/v4/letter/r/5f9b8f/32.png) [@rrobbins](https://forum.kirupa.com/u/rrobbins)\
**Post date:** [April 16, 2007, 9:38pm UTC](https://forum.kirupa.com/t/sliding-menu-troubles-help-needed/222776/1 "2007-04-16T21:38:07Z")

</div>

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&lt;=_root.finalDestination) {
		dir = 1;
	} else if (currentPosition&gt;_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)&lt;=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); 
};
```
