Hi,
I need help. I think I’m going blind, to make sure I wonder if anyone else can find an error in the following code.
In short, the .swf gets a list of imagenames in XML format, parses that then proceeds to load the first image in the list. Only thing is, nothing happens. See results below.
var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();
var imageLoader:Loader;
var imageList:XMLList;
var imagePosition:int = 0;
var totalNumberOfImages:int = 0;
var showImage:MovieClip = new MovieClip();
showImage.width = 750;
showImage.height = 450;
showImage.x = 0;
showImage.y = 0;
addChild(showImage);
xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
xmlLoader.load(new URLRequest("http://localhost/sydpol/GetImageListAsXML.php"));
function LoadXML(e:Event):void {
xmlData = new XML(e.target.data);
imageList = xmlData.children();
trace(imageList);
SwapImage();
}
function SwapImage():void {
if(imagePosition > totalNumberOfImages){
imagePosition = 0;
}
var url:String = imageList[imagePosition].@src;
trace(url);
trace("http://localhost/sydpol/" + url);
imageLoader = new Loader();
imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, ImageLoaded);
imageLoader.load(new URLRequest("http://localhost/sydpol/" + url));
imagePosition++;
}
function ImageLoaded(e:Event):void {
showImage.addChild(this.imageLoader);
trace("Image is loaded");
}
Trace result:
<image src=“images/1.jpg”/>
<image src=“images/2.jpg”/>
<image src=“images/3.jpg”/>
<image src=“images/4.jpg”/>
<image src=“images/5.jpg”/>
<image src=“images/6.jpg”/>
images/1.jpg
http://localhost/sydpol/images/1.jpg
Image is loaded
Actual result:
No fri#¤in image.
Thanks!