# Sliding menu problem

**URL:** https://forum.kirupa.com/t/sliding-menu-problem/257127
**Category:** Uncategorized
**Created:** [April 10, 2008, 1:44pm UTC](https://forum.kirupa.com/t/sliding-menu-problem/257127 "2008-04-10T13:44:59Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![tunefuldesign](https://avatars.discourse-cdn.com/v4/letter/t/87869e/32.png) [@tunefuldesign](https://forum.kirupa.com/u/tunefuldesign)
#### Post date: [April 10, 2008, 1:44pm UTC](https://forum.kirupa.com/t/sliding-menu-problem/257127/1 "2008-04-10T13:44:59Z")

</div>

hey guys, i’m new with flash, and i’m working on a website based on the sliding menu tutorial found here: [http://www.kirupa.com/developer/flash8/slidingMenu.htm](http://www.kirupa.com/developer/flash8/slidingMenu.htm)  
i finished it, but it doesn’t work 100%. The problem is that when i click on a button the content slides, but it slides too far. i can’t get it right after trying a lot of things and reading a lot of articles about sliding.  
i hope somebody can help me, because i really like the slide effect 🙂

thanks, tunefuldesign

here’s the swf: [http://www.tunefuldesign.com/fl/main.swf](http://www.tunefuldesign.com/fl/main.swf)  
the .fla: [http://www.tunefuldesign.com/fl/mainbackup.fla](http://www.tunefuldesign.com/fl/mainbackup.fla)  
and the code:

```auto
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);
};

```
