Hi all!!
Before I continue working with this, I was thinking some clever mind had a solution to this.
What I want to achieve is to have a smart dynamic image gallery that reads the nodes from an xml sheet in order to set the number of images to be loaded in the container that I have on stage.
Then when the user clicks the two hit areas I have (prev & next), the script checks for the number in the XMLList that is currently being targeted, and loads the next or the previous image in the sequence of images written in the xml file. And also loops it when the last image in the list has been pressed!
This is what I have so far.
var imageLoader:Loader;
var xml:XML;
var xmlList:XMLList;
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.load(new URLRequest("data/images.xml"));
xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);
function xmlLoaded(event:Event):void
{
xml = XML(event.target.data);
xmlList = xml.children();
{
imageLoader = new Loader();
imageLoader.load(new URLRequest(xmlList[0].attribute("source")));
container_mc.addChild(imageLoader);
}
}
prev_btn.addEventListener(MouseEvent.CLICK, prev);
function prev(event:MouseEvent):void
{
trace("click prev");
}
next_btn.addEventListener(MouseEvent.CLICK, next);
function next(event:MouseEvent):void
{
trace("click next");
}
Can I store an array from the nodes of the xml list, so it automatically starts from the beginning when the last image has been chosen? Or does someone have a better solution to the issue?
I was planning on writing something like, for(var i:int = 0; i < xmlList.length(); i++) but then I would have to have some sort of if statement in there and confuse everything
Oh well, hope someone has had this problem solved before me and is willing to share his/her experience with me!
Thanks in advance
/rundevo