Basic Sliding Menu/Navigation with Easing

Hey everyone,
Here is a file that I was working on earlier today. It is a sliding menu with a slight ease. Depending on how much free time I have, I might make a tutorial out of this.

Here is the code:


var currentPosition:Number = contentHold.content1._x;
var startFlag = 0;
menuSlide = function (input:MovieClip) {
	if (startFlag == 0) {
		
		startFlag = 1;
		
		var finalDestination:Number = input._x;
		var distanceMoved:Number = 0;
		var distanceToMove:Number = Math.abs(finalDestination-currentPosition);
		var finalSpeed:Number = 5;
		var currentSpeed:Number = 0;
		var dir:Number = 1;
		
		if (currentPosition<=finalDestination) {
			dir = -1;
		} else if (currentPosition>finalDestination) {
			dir = 1;
		}
		
		this.onEnterFrame = function() {
			currentSpeed = Math.round((distanceToMove-distanceMoved+1)/finalSpeed);
			distanceMoved += currentSpeed;
			contentHold._x += dir*currentSpeed;
			if (Math.abs(distanceMoved-distanceToMove)<=1) {
				contentHold._x = maskMovie._x-currentPosition+dir*distanceToMove;
				currentPosition = input._x;
				startFlag = 0;
				delete this.onEnterFrame;
			}
		};
	}
};
b1.onRelease = function() {
	menuSlide(contentHold.content1);
};
b2.onRelease = function() {
	menuSlide(contentHold.content2);
};
b3.onRelease = function() {
	menuSlide(contentHold.content3);
};
b4.onRelease = function() {
	menuSlide(contentHold.content4);
};
b5.onRelease = function() {
	menuSlide(contentHold.content5);
};

Cheers!
Kirupa :cowboy:

you have to go to the align tool and set it to top left for each content box. I’m pretty sure that is your problem. Send me your fla if you still have problems with it

Is it hardcoded or does it check the exact width of each movieclip and then tells the script how much to scroll?
Sorry for the stupid question (:P) But all the menus ive seen like this are hard coded :o

here’s what i’ve done with kirupa’s menu. i’m going to put it on a site i’m working on, but basically when you press a button, you get a random sentence that slides over. there’s only 15 sentences right now, as a test, taken from the oxford english dictionary, so you might get a lot of repetition. anyways…feedback is welcome. :be:

Hi guys this is my first post. I liked the menu system kirupa’s but when i did the test doesn’t work correctly, but yours posts help me to resolve the problem. I integrated the menu in my recent proyect. Thanks and excuse me for my bad english.:pir:

@asael2 you scaled the first contenthold mc why did you do that. that is what is causing the shift. it needs to be 100percent by 100 percent. same as your hold mc has to be 100percent as well. and why did you space your 5 mcs should be stacked one beside the other

if you can’t figure it out still i will send the fla. i just want you to realize the simple error that you did