Simple Flash Gallery from folder Image


Hi, Follow the folling steps to create a simple and good image gallery.

Step1:- In gallery  folder place 10 image with serial name like image1.jpg, image2.jpg etc.

Step2. start flash take as3 file.


Step3. on layer 1 type the following script.


var a=1;
var xpos:Number=200;
var ypos:Number=200;


var loader:Loader=new Loader();
var defaultimg:URLRequest=new URLRequest("gallery/image1.jpg");
loader.load(defaultimg);
loader.x=xpos;
loader.y=ypos;

addChild(loader);


btn_nxt.addEventListener(MouseEvent.CLICK,fn_next);

function fn_next(event:MouseEvent) {
removeChild(loader);
a++;
var nimg:URLRequest=new URLRequest("gallery/image"+a+".jpg");
        loader.load(nimg);
addChild(loader);
        loader.x=xpos;
        loader.y=ypos;

}



btn_pre.addEventListener(MouseEvent.CLICK,fn_prev);

function fn_prev(event:MouseEvent) {
removeChild(loader);
a--;
var nimg:URLRequest=new URLRequest("gallery/image"+a+".jpg");
        loader.load(nimg);
addChild(loader);
        loader.x=xpos;
        loader.y=ypos;

}

Step4. on layer 2. create 2 buttons change their instance name as shown in image
Button next instance name:-btn_nxt
Button previous instance name:-btn_pre


Step5:-save flash   file outside the gallery folder and run it as swf..







No comments:

Post a Comment

Things Web Developers Must Include in Their Portfolio

1. Need to have Link and Screen shot of their past projects 2. If they are applying for a specific skill like PHP or ASP.Net. Need to...