Posted By

adamcoulombe on 07/09/10


Tagged

flash xml slideshow as3 loadermax


Versions (?)

Who likes this?

9 people have marked this snippet as a favorite

palo
davidino1978
donaldleegraham
tspitzr
tombarc
mitien
ckueda
mecsekikrisztian
mediapoint


Simple Flash / AS3 Slideshow using GreenSock LoaderMax


 / Published in: ActionScript 3
 

URL: http://adamcoulombe.info/lab/as3/loadermaxslideshow/

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.

  1. //Get the LoaderMax and GreenSock classes at http://www.greensock.com/
  2.  
  3. import com.greensock.*;
  4. import com.greensock.loading.*;
  5. import com.greensock.events.LoaderEvent;
  6. import com.greensock.loading.display.*;
  7.  
  8. var xml:XMLLoader;
  9. var images;
  10. var current = 0;
  11. var previous;
  12.  
  13. function init(){
  14. LoaderMax.activate([ImageLoader]);
  15. xml = new XMLLoader("images.xml", {name:"images", onComplete:onXmlLoaded});
  16. xml.load();
  17. }
  18.  
  19. function onXmlLoaded(e){
  20. images = LoaderMax.getContent("images");
  21. nextImage();
  22.  
  23. }
  24.  
  25. function nextImage(){
  26.  
  27. TweenLite.from(images[current],1,{alpha:0,
  28. onStart:function(){
  29. addChild(images[current]);
  30. },
  31. onComplete:function(){
  32. if(previous){
  33. removeChild(images[previous])
  34. }
  35. previous = current;
  36. if(current<images.length-1){
  37. current++;
  38. }else{
  39. current=0;
  40. }
  41. setTimeout(nextImage,2000);
  42. }
  43. });
  44. }
  45.  
  46.  
  47. init();

Report this snippet  

You need to login to post a comment.