# HELP! - change variables - next/prev buttons \[fmx\]

**URL:** <https://forum.kirupa.com/t/help-change-variables-next-prev-buttons-fmx/19299>\
**Category:** flash\
**Created:** [April 26, 2003, 7:53am UTC](https://forum.kirupa.com/t/help-change-variables-next-prev-buttons-fmx/19299 "2003-04-26T07:53:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![liquivision](https://avatars.discourse-cdn.com/v4/letter/l/ba8739/32.png) [@liquivision](https://forum.kirupa.com/u/liquivision)\
**Post date:** [April 26, 2003, 7:53am UTC](https://forum.kirupa.com/t/help-change-variables-next-prev-buttons-fmx/19299/1 "2003-04-26T07:53:23Z")

</div>

I’m in a tight spot.  
I have a movie which consists of 4 buttons( PLAY, PREVIOUS, NEXT and STOP)

//define variable  
currentSlide = 1

//next button with the code  
on (release) {  
currentSlide = currentSlide+1;  
if (currentSlide\<=4) {  
allunits.gotoAndPlay(“slide”+currentSlide);  
} else {  
gotoAndPlay(“end”);  
}  
}

//Previous button with the code  
on (release) {  
currentSlide = currentSlide-1;  
if (currentSlide\<=0) {  
allunits.gotoAndPlay(“slide”+currentSlide);  
} else {  
gotoAndPlay(“start”);  
}  
}

//Play button  
currentSlide = currentSlide + 1

These buttons work correctly and advance or reverse in sequencial order (slide1,slide2,slide3,slide4). However the movie can run from start to finish wihtout the use of the navigation.

My problem is that if I let the movies run independently and then choose to use the next button while(for example) “slide3” is playing, the movie jumps to “slide1”. Note that these slide labels are located within movieclip named “allunits”

I know that the variable currentSlide is still equal to 1 thus returning the playhead to label “slide1”.

I need help targeting the correct slide#

Can anyone help!  
Thanks

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 26, 2003, 8:20am UTC](https://forum.kirupa.com/t/help-change-variables-next-prev-buttons-fmx/19299/2 "2003-04-26T08:20:56Z")

</div>

maybe you should add blank keyframes or keyframes inside your animation at certain stages, defining the \<\< current slide \>\> variable… That means when your animation reaches a certain point the \<\<current slide\>\> will change…  
or maybe you should think about using the \_currentframe function –

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [April 26, 2003, 9:16am UTC](https://forum.kirupa.com/t/help-change-variables-next-prev-buttons-fmx/19299/3 "2003-04-26T09:16:41Z")

</div>

would I place the new value to the var currentSlide on the frames labeled “slide”. If so does the A/S look like this:

//currentSlide will equal 1 thru 4  
currentSlide = 1;

How would the A/S look like if I was to use function(); ?

Also what did you mean \<\< currentSlide \>\> ?

Thanks
