Loading images sequentially from an XML file

Posted by johnnyc333 
Loading images sequentially from an XML file
June 11, 2009 10:46PM
I have a flash movie which loads a single image from an xml file into a UILLoader inside a FlashEff enhanced MC (FESFlashSlide). How would I modify the code below so that it would load a different image every 4 seconds or whenever it returns to frame 1 (which would be a better way to do it if that's possible). I've attached the FLA in case that helps.

Thanks,

John

SCRIPT:
var myXML:XML;

var myLoader:URLLoader = new URLLoader();
myLoader.load(new URLRequest("cars.xml"));
myLoader.addEventListener(Event.COMPLETE, processXML);
function processXML(e:Event):void {
myXML = new XML(e.target.data);

for (var i:int = 0; i<myXML.*.length(); i++){

ldr1.source = myXML.image[1] //instance of UILoader

};

ldr1.addEventListener(Event.COMPLETE, completeHandler);
function completeHandler(event:Event):void {
fe1.show() //instance of flasheff component
}
}
Attachments:
open | download - XMLLoader.fla (1.36 MB)
Re: Loading images sequentially from an XML file
June 12, 2009 09:13AM
Hi Jhon, here is what you should do:
In the processXML function write

var myLoader:URLLoader = new URLLoader();
myLoader.load(new URLRequest("cars.xml"));
myLoader.addEventListener(Event.COMPLETE, processXML);

write

var timer:Timer = new Timer(4000);
timer.addEventListener(TimerEvent.TIMER, blah);
timer.start();
function blah(e:TimerEvent):void{
ldr.source = whatever image you want to load next.
}

Hope this helps
Re: Loading images sequentially from an XML file
July 13, 2009 09:37AM
Hi Ionut, I just happened to be going through old emails and noticed that there was in fact a response to my question from a month ago! Thanks. I don't know how I missed it but I hope you're still available to help me with this. Could you please modify my AS to include your solution, and reprint the entire code with your solution.

ldr1.source = myXML.image[1] refers to the second of the3 images listed in examples.xml, and of course that image keeps being loaded every 4 seconds which is the length of the timeline.

HERE IS THE XML:

<?xml version=1.0 encoding=UTF-8 ?>
<galery>
<image>exhaust.jpg</image>
<image>grille.jpg</image>
<image>wheels.jpg</image>
</galery>


AND HERE IS MY ACTION SCRIPT:

var myXML:XML;
var myLoader:URLLoader = new URLLoader();
myLoader.load(new URLRequest("example.xml"));
myLoader.addEventListener(Event.COMPLETE, processXML);
function processXML(e:Event):void {
myXML = new XML(e.target.data);

for (var i:int = 0; i<myXML.*.length(); i++)
{
ldr1.source = myXML.image[1] // instance name of the UILoader
};

ldr1.addEventListener(Event.COMPLETE, completeHandler);
function completeHandler(event:Event):void {
fe1.show() //instance name of the FlashEff component
}
}

I hope this is enough for you to nail this problem for me.

Thanks!
John
Sorry, you do not have permission to post/reply in this forum.