SLIDE.FLA
Código ActionScript :
import gs.*; import gs.easing.*; var xmlPath = "content.xml"; var photos_xml = new XML(); photos_xml.ignoreWhite = true; var imageList:Array = new Array(); photos_xml.onLoad = function(success) { if (success) { // ----------- load successful imageList = photos_xml.firstChild.childNodes; myText_txt = photos_xml.firstChild.childNodes; loadImage(); } else { // ----------- problem loading, check path trace("Error loading photos_xml"); } } var currentImage:Number = 0; var imageLoader:MovieClipLoader = new MovieClipLoader(); var loadListener:Object = new Object(); imageLoader.addListener(loadListener); loadListener.onLoadInit = function(target_mc:MovieClip, httpStatus:Number):Void { TweenLite.to(shell_mc.background_mc, 0.25, {_width:target_mc._width + 20, _height:target_mc._height + 20, ease:Quad.easeOut}); TweenLite.to(shell_mc.border_mc, 0.25, {_width:target_mc._width, _height:target_mc._height, ease:Quad.easeOut}); TweenLite.to(shell_mc.mask_mc, 0.25, {_width:target_mc._width, _height:target_mc._height, ease:Quad.easeOut}); var clipXTarg = Math.round((Stage.width/2)-((target_mc._width+20)/2)); var clipYTarg = Math.round((Stage.height/2)-((target_mc._height+20)/2)); TweenLite.to(shell_mc, 0.25, {_x:clipXTarg, _y:clipYTarg, ease:Quad.easeOut}); if(currentImage == 0){ var prevImgNum = imageList.length -1; }else{ var prevImgNum = currentImage - 1; } var prevImg = shell_mc.pics_mc["pic"+prevImgNum]; TweenLite.to(prevImg, 0.25, {autoAlpha:0, onComplete:removePrevious}); } loadListener.onLoadComplete = function(target_mc:MovieClip):Void { TweenLite.to(target_mc, 0.25, {autoAlpha:100, delay:0.25}); setTimer(); } function setTimer(){ timer = setInterval(loadImage, 5000); } function removePrevious(){ if(prevImg != undefined){ removeMovieClip(prevImg); } if(currentImage < imageList.length -1){ currentImage = currentImage + 1; }else{ currentImage = 0; } } function loadImage(){ var loadURL = imageList[currentImage].attributes.imgurl; var targetClip = shell_mc.pics_mc.createEmptyMovieClip("pic"+currentImage,shell_mc.pics_mc.getNextHighestDepth()); targetClip._alpha = 0; clearInterval(timer); imageLoader.loadClip(loadURL,targetClip); } photos_xml.load(xmlPath); stop();
CONTENT.XML
Código XML :
<?xml version='1.0' encoding='UTF-8'?> <gallery> <image imgurl="fotos/4.jpg" name="Market Walk"></image> <image imgurl="fotos/5.jpg"></image> <image imgurl="fotos/6.jpg"></image> <image imgurl="fotos/7.jpg"></image> <image imgurl="fotos/8.jpg"></image> <image imgurl="fotos/9.jpg"></image> </gallery>