I am trying to build a type of slideshow but I dont really know how to tell the actionscript that when I click next button it should proform the next image function and same for the previous button…
I have a bit of code like this:(which operates a component I am using)
//the time in miliseconds, which is between images
var slideShowDelay:Number=1500;
//curent position
var curentPosition:Number=0;
//the number of the images, from the xml
var totalImages:Number=0;
var intervalId:Number;
var imagesArray:Array=[]
var isSliding:Boolean=false;
var _xml:XML;
var me=this;
//method used to start the slideshow
function startSlideShow()
{
isSliding=true;
showNextImage();
}
//method used to stop the slideshow
function stopSlideShow()
{
clearInterval(intervalId);
isSliding=false;
}
//method used to play the next image from the slideshow
function showNextImage()
{
loadImage(curentPosition+1);
}
//method used to play the previous image from the slideshow
function showPreviousImage()
{
loadImage(curentPosition-1);
}
/**
method used to jump to a specified index
usage: loadImage(3);
*/
function loadImage(nr:Number)
{
//cecking if the nr is between 0 and totalImage
if(nr>totalImages-1)
nr=0;
if(nr<0)
nr=totalImages;
//set the curent position to the new one
curentPosition=nr;
//start loading the new image
me.ldr.contentPath=me.imagesArray[curentPosition];
//clear the interval used for slideshow
clearInterval(me.intervalId)
}
//a listener, used to know when the transition has finished
var obj={};
obj.onTransitionEnd=function()
{
if(me.isSliding==true)
me.intervalId = setInterval(me,"showNextImage", me.slideShowDelay )
}
ldr.addEventListener("onTransitionEnd", obj)
//loading the xml file.
_xml=new XML();
_xml.load("test.xml")
_xml.ignoreWhite=true
_xml.onLoad=function(succes)
{
if(succes)
{
//parsing the xml, and push the images path to imagesArray
for(var aNode=this.firstChild.firstChild;aNode!=null; aNode=aNode.nextSibling)
{
me.imagesArray.push(aNode.attributes.path);
}
me.totalImages=this.firstChild.childNodes.length;
//start the slideshow
me.startSlideShow();
}
}
I figure it is in this part that I need to make some changes. But what I am stuck with is if I give my buttons instance names like nxt_btn and prv_btn how do I get them interacting with these functions?
//method used to play the next image from the slideshow
function showNextImage()
{
loadImage(curentPosition+1);
}
//method used to play the previous image from the slideshow
function showPreviousImage()
{
loadImage(curentPosition-1);
}
Sorry if that is unclear but I dont really understand lol.