Tuesday, July 15, 2008

Flash Slideshow With XML

Paste the below coding in a actionscript file

function loadXML(loaded)
{
if (loaded)
{
xmlNode = this.firstChild;
image = [];
description = [];
linkDetails = [];
total = xmlNode.childNodes.length;
i = 0;
while (i < text =" _root.linkDetails;" content = "no file loaded!" loaded ="=" _alpha =" 0;" text =" description[p];"> 0)
{
--p;
picture._alpha = 0;
picture.loadMovie(image[p], 1);
desc_txt.text = description[p];
picture_num();
}
}

function firstImage()
{
if (loaded == filesize)
{
picture._alpha = 0;
picture.loadMovie(image[0], 1);
desc_txt.text = description[0];
link.text = link[0];
picture_num();
}
}

function picture_num()
{
current_pos = p + 1;
pos_txt.text = current_pos + " / " + total;
}

_global.slideshow = "on";
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("images.xml");
//xmlData.load("images.php");
listen = new Object();
listen.onKeyDown = function ()
{
if (Key.getCode() == 37)
{
prevImage();
return;
}

if (Key.getCode() == 39)
{
nextImage();
}

}

Key.addListener(listen);
previous_btn.onRelease = function ()
{
prevImage();
}

next_btn.onRelease = function ()
{
nextImage();
}

p = 0;
this.onEnterFrame = function ()
{
filesize = picture.getBytesTotal();
loaded = picture.getBytesLoaded();
preloader._visible = true;
if (loaded == filesize)
{
preloader._visible = false;
if (picture._alpha < _alpha =" picture._alpha" _xscale =" 100" slideshow ="=" now =" getTimer();"> flip)
{
if (p > total - 2)
{
p = 0;
flip = flip + 4000;
firstImage();
return;
}

flip = flip + 4000;
nextimage();
}

}
}

Your Actionscript file is ready then create a xml file with datas in the format given below :
<1?xml version="1.0" encoding="UTF-8">
<1images>
<1pic>
<1image>slideshow/_01.jpg<1/image>
<1caption>ssfsdlfjsdlfjsdla <1/caption>
<1/pic>
<1pic>
<1image>slideshow/_01.jpg<1/image>
<1caption>ssfsdlfjsdlfjsdla <1/caption>
<1/pic>
<1pic>
<1image>slideshow/_01.jpg<1/image>
<1caption>ssfsdlfjsdlfjsdla <1/caption>
<1/pic>

<1/images>
*Remove 1 in every html tag
For demo Check : Liveindiacuisine.com

No comments: