...

View Full Version : slideshow transition problem



hozmat
02-05-2009, 06:49 AM
I have a slideshow in CS3 (using AS2). Its working fine. I want to add a mx transition to it like a wipe or a tween.
Currently there is a alpha given to the next and previous image, but I feel the transition is not smooth enough. I would like to apply the MX Transition effect to this code.
The other feature of this slideshow is that the first image loaded is a random image. Please HELP to add the MX Transition code.

Flash Code:




function loadXML(loaded)
{
if (loaded)
{
xmlNode = this.firstChild;
image = [];
caption = [];
total = xmlNode.childNodes.length;
for (i = 0; i < total; i++)
{
image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
caption[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;

} // end of for
firstImage1();
}
else
{
content = "file not loaded!";
} // end else if
} // End of the function

function nextImage()
{
previous_btn._alpha = 100;
nextImg = startImgNo + 1;
if(nextImg < total)
{
picture._alpha = 0;
picture.loadMovie("photos/" + image[nextImg], 1);
caption_txt.text = caption[nextImg];
if(nextImg == (total-1))
next_btn._alpha = 50;
startImgNo = nextImg;
}
} // End of the function

function prevImage()
{
next_btn._alpha = 100;
prevImg = startImgNo - 1;

if(prevImg >= 0)
{
picture._alpha = 0;
picture.loadMovie("photos/" + image[prevImg], 1);
caption_txt.text = caption[prevImg];
if(prevImg == 0)
previous_btn._alpha = 50;
startImgNo = prevImg;
}



} // End of the function

function firstImage1()
{
if (loaded == filesize)
{
var rand_no = Math.round(Math.random()*(total-1));

if(rand_no >= 0 && rand_no < total)
{
picture.loadMovie("photos/" + image[rand_no], 1);
caption_txt.text = caption[rand_no];
if(rand_no == (total-1))
next_btn._alpha = 50;
if(rand_no == 0)
previous_btn._alpha = 50;
}
startImgNo = rand_no;
} // end if
} // End of the function

xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("photos.xml");
var startImgNo;
var total = xmlNode.childNodes.length;
listen = new Object();
listen.onKeyDown = function ()
{
if (Key.getCode() == 37)
{
prevImage();
}
else if (Key.getCode() == 39)
{
nextImage();
} // end else if
};
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.preload_bar._xscale = 100 * loaded / filesize;
}
else
{
preloader._visible = false;
if (picture._alpha < 100)
{
picture._alpha = picture._alpha + 10;
} // end if
} // end else if
};



XML Code:


<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<images>
<pic>
<image>ice1.jpg</image>
<caption>Cheery Pie ala Mode</caption>
</pic>
<pic>
<image>ice2.jpg</image>
<caption>Ice Cream Dessert</caption>
</pic>
<pic>
<image>ice3.jpg</image>
<caption>Ice Cream Tower</caption>
</pic>
<pic>
<image>ice4.jpg</image>
<caption>Ice Cream and Raspberries</caption>
</pic>
<pic>
<image>ice5.jpg</image>
<caption>Iced Dessert </caption>
</pic>



I have also attached a zip file which has all the files.

gnomeontherun
02-05-2009, 10:05 AM
http://codingforums.com/showthread.php?t=129968

Similar thread with details on how to merge.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum