very cool 3.d slide show tutorial using xml

http://www.kirupa.com/forum/showthread.php?t=245468

This is the link for the tutorial that focuses on the AS seen below

// variables
var xmlList:XMLList;
var mcLoader:Loader;
var slideNum:Number = 0;

// loads xml and assigns the text field the first node using the slideNum variable from above
var xml:XML = new XML();
var loader:URLLoader = new URLLoader();
loader.load(new URLRequest(”images.xml”));
loader.addEventListener(Event.COMPLETE,
function(evt:Event):void {
xml = XML(evt.target.data);
xmlList = xml.children();
trace(xmlList);
imageText.text = xml.image[slideNum].@name.toString();
}
);

// stage event listeners for the movieClip buttons
nextBtn.addEventListener(MouseEvent.CLICK, onClickNextSlide);
prevBtn.addEventListener(MouseEvent.CLICK, onClickPrevSlide);

// this function will change the text depending upon which number is fed to the var slideNum in the onClickNextSlide function
function changeText(slideNum:Number):void {
imageText.text = xml.image[slideNum].@name.toString();
}
changeText(0);

// this function adds 1 to the current number, if the current number is 4, it starts over
function onClickNextSlide(event:MouseEvent):void {
slideNum++;
trace(slideNum);
if (slideNum == 4) {
slideNum = 0;
}
changeText(slideNum);
}
// this function dos the opposite of the one above, it subtracts 1 to current number, when it reaches 0 it starts back at 4
function onClickPrevSlide(event:MouseEvent):void {
slideNum–;
trace(slideNum);
if (slideNum == 0) {
slideNum = 4;
}
changeText(slideNum);
}



No Responses Yet to “actionscript 3.0 for slideshow”  

  1. No Comments Yet

Leave a Reply