PDA

View Full Version : Help: add BACK/FORWARD buttons to Sliding Menu?



aioros
September 26th, 2007, 05:16 PM
hi everyone,
i followed the tutorial for the (Sliding Menu (http://www.kirupa.com/developer/flash8/slidingMenu.htm)), with success!

Now I would like to add a Forward and Back button to the menu.
So no matter what movie clip loads, it can go back to the previous
or on to the next one (in order).

I've been trying to add the function to a button on the AS but
it doesn't work:


bf.onRelease = function() {
menuSlide(contentHold.currentPosition_+1);
};


bf is my "Button Forward"...

can anyone help with this?

thank you! C:-)


(and one more non-important thing: if i make the buttons roll over to different colors, can they "STAY rolled over" when their corresponding slide is showing?)

Segatta
January 7th, 2009, 06:16 PM
I'm looking for exact same thing !

BenBart
January 7th, 2009, 06:45 PM
Declare a variable at the top of your script to track what your current movie is.

var currentMovie:Number = 1;

Anytime you switch to a new slide, you need to update that number.

Then make a function that adds a number to that currentMovie to go forward, and calls the menuSlide function.


bf.onRelease = function(){
currentMovie ++;
menuSlide(contentHold["content"+currentMovie]);
}

Segatta
January 8th, 2009, 05:16 AM
Ok, I feel really stupid, but i'm new to the whole flash scripting thing...

- How do I update the currentMovie variable everytime a button is clicked?

- I tried making a "previous button". I was thinking I could do this by replacing the plus in the code below by a minus, appently not :p

I used following code:

bf.onRelease = function(){
currentMovie ++;
menuSlide(contentHold["content" - currentMovie]);
}

Some help please...

P.S.: Once i'm done i'll be glad to share the code with the whole community... :-)

BenBart
January 8th, 2009, 11:20 PM
Ok, I feel really stupid, but i'm new to the whole flash scripting thing...

- How do I update the currentMovie variable everytime a button is clicked?

- I tried making a "previous button". I was thinking I could do this by replacing the plus in the code below by a minus, appently not :p

I used following code:

bf.onRelease = function(){
currentMovie ++;
menuSlide(contentHold["content" - currentMovie]);
}

Some help please...

P.S.: Once i'm done i'll be glad to share the code with the whole community... :-)

I don't have the code in front of me, but I remember that for each button there was a function something like:



button1.onRelease = function(){
menuSlide(contentHold.content1);
}

So to update the new variable with the current content you would add in a line of code:



button1.onRelease = function(){
currentMovie = 1;
menuSlide(contentHold.content1);
}

Also the code I gave you before doesn't take in to account that there are only 5 buttons.


bf.onRelease = function(){
//Add 1 to currentMovie;
currentMovie ++;

//check to see if this is past the last contentHold
if(currentMovie>5){
//if it's larger than 5, the last contentHold, it resets to 0;
currentMovie = 0;
}
menuSlide(contentHold["content"+currentMovie]);
}

Now to make a back button, do the same thing, but in reverse.


bf.onRelease = function(){
//Subtract 1 to currentMovie;
currentMovie --;

//check to see if this is past the first contentHold
if(currentMovie<0){
//if it's smaller than, the first contentHold, it sets itself to the last one;
currentMovie = 5;
}

menuSlide(contentHold["content"+currentMovie]);
}