# Sliding menu problem

**URL:** <https://forum.kirupa.com/t/sliding-menu-problem/198271>\
**Category:** Uncategorized\
**Created:** [August 23, 2006, 4:49pm UTC](https://forum.kirupa.com/t/sliding-menu-problem/198271 "2006-08-23T16:49:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![maryc](https://avatars.discourse-cdn.com/v4/letter/m/b9e5f3/32.png) [@maryc](https://forum.kirupa.com/u/maryc)\
**Post date:** [August 23, 2006, 4:49pm UTC](https://forum.kirupa.com/t/sliding-menu-problem/198271/1 "2006-08-23T16:49:35Z")

</div>

I’ve been trying to incorporate a sliding menu into my project. I’ve duplicated it a few times and can’t seem to get it to work within my project after 6 hours of trying. seems so simple. - I’ve coded the two buttons at the bottom as b1 and b2 and the contentHold mc has content1 and 2 mc’s  
here’s the code.given all mc’s instance names as well. Any other way to do a simple sliding gallery?

var currentPosition:Number = contentHold.content1.\_x;  
var startFlag:Boolean = false;  
menuSlide = function (input:MovieClip) {

if (startFlag == false) {

startFlag = true;

var finalDestination:Number = input.\_x;  
var distanceMoved:Number = 0;  
var distanceToMove:Number = Math.abs(finalDestination-currentPosition);  
var finalSpeed:Number = .3;  
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 = false;  
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);

};
