Noob needs help with this code... ;)

Hi,

I found this code in a nice tutorial and I wanna make slight adjustments to the code.

Unfortunately my Action Script skills are very limited… :wink:

This is the code for a ‘sliding menue’, depending on which button u pressed it will ‘slide’ to the appropriate picture.

Here’s the code:

var currentPosition:Number = large_pics.pic1._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 = .2;
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;
large_pics._x += dir
currentSpeed;
if (Math.abs(distanceMoved-distanceToMove)<=1) {

large_pics._x = mask_pics._x-currentPosition+dir*distanceToMove;
currentPosition = input._x;
startFlag = false;
delete this.onEnterFrame;

}

};

}

};
b1.onRelease = function() {

menuSlide(large_pics.pic1);

};
b2.onRelease = function() {

menuSlide(large_pics.pic2);

};
b3.onRelease = function() {

menuSlide(large_pics.pic3);

};
b4.onRelease = function() {

menuSlide(large_pics.pic4);

};

I need to adjust five things in this code…

(1) I want this menue to slide vertically not horizontally.

I changed the ‘x’ values in the code to ‘y’ which I thought would make it move vertically, but it doesn’t work…

(2) Is it possible that, whatever the distance is, the “sliding” time is always 2.2 sec ?

(3) I need to implement code that after the final position is reached, the timeline jumps to a certain movieclip to a certain label - depending on what button was pressed of course…

I tried to implement this code for button number two…

b2.onRelease = function() {

menuSlide(large_pics.pic2);

}

if (currentPosition = finalDestination) {

this.large_pics.pic2.gotoAndPlay(“s1”);

};

–> sliding still works but it doesn’t jump to the appropriate label…

(4) I wanna add ‘Next’ & ‘Previous’ buttons to the slide show - what would be the code in this case scenario ?

My first thought was something like that Flash checks which ‘pic’ movieclip it is showing right now (pic1, pic2, pic3 etc.) and depending on what button u pressed u go to the y value of movieclip ‘picX + 1’ (Next button) or ‘picX - 1’ (Previous button)…

Is that possible ?

(5) After implementing the Next & Previous buttons I need to make sure that when it reached the last pic movieclip it will not go further on the y value - because there is no more pic movieclip.

Options are to either slide back to movieclip ‘pic1’ or simply do nothing any more on the next button…

I know this is probably Kindergarten for you, but I have only slight ideas how to do this and no code knowledge to back it up… haha

Thanx a lot for your help in advance !

Always a pleasure to learn from u guys… :wink:

Mike