/ Published in: ActionScript 3
Basic usage of GreenSock\'s LoaderMax class for AS3. A simple slideshow controlled via XML.\r\n\r\nGo to http://adamcoulombe.info/lab/as3/loadermaxslideshow/ for demo and downloads.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
//Get the LoaderMax and GreenSock classes at http://www.greensock.com/ import com.greensock.*; import com.greensock.loading.*; import com.greensock.events.LoaderEvent; import com.greensock.loading.display.*; var xml:XMLLoader; var images; var current = 0; var previous; function init(){ LoaderMax.activate([ImageLoader]); xml = new XMLLoader("images.xml", {name:"images", onComplete:onXmlLoaded}); xml.load(); } function onXmlLoaded(e){ images = LoaderMax.getContent("images"); nextImage(); } function nextImage(){ TweenLite.from(images[current],1,{alpha:0, onStart:function(){ addChild(images[current]); }, onComplete:function(){ if(previous){ removeChild(images[previous]) } previous = current; if(current<images.length-1){ current++; }else{ current=0; } setTimeout(nextImage,2000); } }); } init();
URL: http://adamcoulombe.info/lab/as3/loadermaxslideshow/