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

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

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 –

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