Join Login


Video Tutorials
Blog



Adobe Production Premium CS5.5

Create an Image Gallery with Next and Previous Buttons


By: RiverCityGraphix      Views: 35511      Share: Bookmark and Share

In this tutorial, you will learn how to create an image gallery that uses next and previous buttons to cycle images in Flash CS3.

This Flash image gallery works similarly to my Simple Image Gallery tutorial. Each image has its own frame. This image gallery is run with actionscript that cycles through the frames based on the current frame. Furthermore, it is very expandable and can use many images without appearing cluttered. Keep in mind, if you use triangle buttons like I did you will want to adjust the hit state to the shape of the button. This will give it a more professional feel.

Actionscript 3.0
stop()

btn2.addEventListener(MouseEvent.CLICK, backward);
btn1.addEventListener(MouseEvent.CLICK, forward);

function forward(event:MouseEvent) {
    if (this.currentFrame == this.totalFrames) {
        gotoAndStop(1);
    }
    else {
        nextFrame();
    }
}


function backward(event:MouseEvent) {
    if (this.currentFrame == 1) {
        gotoAndStop(this.totalFrames);
    }
    else
    {
        prevFrame();
    }
}


Actionscript 2.0 (Alternate Code)
stop();

btn1.onRelease = function(){
    if (_currentframe == _totalframes) {
        gotoAndStop(1);
    }
    else {
        nextFrame();
    }
}

btn2.onRelease = function(){
    if (_currentframe == 1) {
        gotoAndStop(_totalframes);
    }
    else {
        prevFrame();
    }
}




Free Source Files Zip

99Designs.com