Using nextFrame(), prevFrame(), and gotoAndStop() to navigate

actionscript-2

I'm trying to make an easy image galleri (one photo each frame), and then two buttons to navigate right/left. When it gets to the final frame, it jumps back to the first if you click next and vice versa for left.

The problem with the code is that I'm only able to jump back to last frame, and forth to first frame again.

Here's the code.

Left button:

on (release) {
if (_currentframe = 1) {
    gotoAndStop(_totalframes);
} else {
   prevFrame();
}    
}

Right button:

on (release) {      
    if (_currentframe = _totalframes) {
    gotoAndStop(1);
    }
    else
    {   
    nextFrame();
    }
}

Best Answer

Made it work by altering the code a bit.

Left button:

on (release) {
    if (_currentframe > 1) {
        prevFrame();
    } else {
        gotoAndStop(_totalframes);
    }
}

Right

on (release) {
    if (_currentframe < _totalframes) {
        nextFrame();
    }
    else
    {   
        gotoAndStop(1);
    }
}
Related Topic