Image Gallery Issue in As3
Hi,
I am trying to implement a simple image gallery with alpha transition using as3. But an issue is occuring with this. After each image alpha transition, the stage becomes blank. The code i have used for image Gallery is following.CAn anybody help me. I am trying this for a week. but still i have a hope for make this working. So please help me.
import flash.display.Loader;
import flash.display.*;
import gs.TweenLite;
const TIMER_DELAY = 2000;
var totImages:Number;
var index:Number = 0;
var imgArr:Array = new Array();
var currentContainer:MovieClip = holder0;
currentContainer.alpha = 0;
var transTimer:Timer = new Timer(TIMER_DELAY);
//transTimer.addEventListener(TimerEvent.TIMER, startTransition);
var imgLoader:Loader = new Loader();
var myXML:XML = new XML();
var XML_URL:String = "images.xml";
var myXMLURL:URLRequest = new URLRequest(XML_URL);
var myLoader:URLLoader = new URLLoader(myXMLURL);
myLoader.addEventListener("complete", xmlLoaded);
function xmlLoaded(event:Event):void{
myXML = XML(myLoader.data);
processXML(myXML);
}
function processXML(xml){
totImages = xml.children().length();
for(var i=0;i<totImages;i++){
var tempVar = xml..item..image;
imgArr.push(tempVar);
}
//transTimer.start();
currentContainer = holder0;
loadImage();
}
function loadImage(){
var url = imgArr[index];
//ImgLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressStatus);
imgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, fadeInImg);
var fileRequest:URLRequest = new URLRequest(url);
imgLoader.load(fileRequest);
currentContainer.addChild(imgLoader);
}
function fadeInImg(e:Event){
TweenLite.to(currentContainer,3,{alpha:1,delay:2,onComplete:switchClip});
}
function switchClip(){
if(index < totImages){
index++;
} else {
index = 0;
}
if(currentContainer == holder0){
currentContainer = holder1;
} else {
currentContainer = holder0;
}
currentContainer.alpha = 0;
MovieClip(this.root).swapChildren(holder0, holder1);
loadImage();
}
Thanks and Regards,
Sreelash
