Flash Image Gallery with Movieclip(XML)

1.Create new flash file for image gallery
2.Create Empty movie clip for image gallery name picture_MC and instance name picture_mc for the movie clip
3.create the xml file for image gallery, this is the xml file for image gallery

<xml>
<images>
<a title = “pic1.jpg” />
<b title = “pic2.jpg” />
<c title = “pic3.jpg” />
</images>
</xml>

4.create new layer and rename it action then press f9 for action panel ,copy the following code and paste the code in the action panel.

pauseTime = 3000;
xmlImages = new XML();
xmlImages.ignoreWhite = true;
xmlImages.onLoad = loadImages;
xmlImages.load(“images.xml”);

function loadImages(loaded) {
if (loaded) {
xmlFirstChild = this.firstChild;
imageFileName = [];
totalImages = xmlFirstChild.childNodes[0].childNodes.length;
for (i=0; i<totalImages; i++) {
imageFileName[i] = xmlFirstChild.childNodes[0].childNodes[i].attributes.title;
}
randomImage();
}
}

function randomImage() {
if (loaded == filesize) {
var ran = Math.round(Math.random() * (totalImages – 1));
picture_mc.loadMovie(imageFileName[ran], 1); pause();
}
}

function pause() {
pauseInterval = setInterval(pause_slideshow, pauseTime);
function pause_slideshow() {
clearInterval(pauseInterval); randomImage();
}
}

then press run for output.

Advertisements

Posted on January 2, 2009, in Flash and tagged , . Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: