RSS
email

Dynamic Image gallery(Fade_In_Out):



This is simple dynamic gallery to Fade in out images...

Note: Using flash8.....



Step1: Open New document in flash (Ctrl + N)


Step2: Select first frame, right-click and paste the below code in first frame

code contains explanations




//importing tween classes
import mx.transitions.Tween;
import mx.transitions.easing.*;
//variables declaration------>
var delay:Number = 5000;//interval between tweens
//array containing image urls
var data_arr:Array = ["http://imagecache2.allposters.com/images/pic/NIM/AF605~Flowers-and-Butterflies-Posters.jpg", "http://www.global-b2b-network.com/direct/dbimage/50322257/Sun_Flowers.jpg", "http://img.alibaba.com/photo/50637711/Simulated_Silk_Luau_Leis__Hibiscus_Flowers.jpg", "http://www.highlandcountryweddings.co.uk/flowers1.jpg"];
var current_num:Number = 0;
var first_num:Number = 0;
_root.createEmptyMovieClip("image_holder", _root.getNextHighestDepth());//empty Movieclip
_root.image_holder._x = 0;
_root.image_holder._y = 0;
//moviecliploader class
var mcl_lis:Object = new Object();
var mcl:MovieClipLoader = new MovieClipLoader();//moviecliploader class to load external files
mcl.addListener(mcl_lis);//adding listener to moviecliploader class
//calling the function for firsttime
load_image();
//
function load_image() {
mcl.loadClip(_root.data_arr[_root.current_num], _root.image_holder);//loading image in the holder
//looping the array values
if (_root.current_num>=data_arr.length-1) {
_root.current_num = _root.first_num;
} else {
_root.current_num++;
}
}
//load init function called when image start loading
mcl_lis.onLoadInit = function(target_mc:MovieClip) {
var obj:Tween = new Tween(target_mc, "_alpha", Normal.easeIn, 0, 100, .8, true);
//timer function to hold tween for some secs
var timer = getTimer();
_root.interval = setInterval(function () {
if ((getTimer()-timer)>delay) {
var obj:Tween = new Tween(target_mc, "_alpha", Normal.easeIn, 100, 0, .8, true);//Tween alpha of Mc from 100 to 0 in duration .8 seconds
obj.onMotionFinished = function() {
load_image();//loading next image from array
};
clearInterval(_root.interval);
}
}, 30);
};

Bookmark and Share

1 comments:

Anonymous said...

THANKS! AWESOME.

This is exactly what I wanted, and it's been ridiculously difficult to find.

Elegant and efficient.

 

Recent Posts

Recent Visitors

Donate Me

About Me

My photo
Chennai, Tamil nadu, India
Nothing more to say about me.. Just a Action Script programmer / Flex developer having 4.5 years of experience.