Dynamic Building Scrolling Gallery - XML - Help
Hey guys,
I'm going crazy here, using up too much time and getting no results.
What I'm trying to do is build a Dynamic XML scrolling gallery, but it's not going to be a gallery, more like scrolling images with links, that when you click on an image, it will take you to the url designated for each image in the XML.
I have no experience working with AS3, so far what I've got are things I'm learning trying to build this.
The issue:
The issue is that when I run the script, the url designated to all the created movie clips have the same url. For example it will use first "link" on the XML on all 4 movie clips (so all the movie clips would be linked to "google.com"), or it will use the last "link" in the XML for all movie clips (so all the movie clips would be linked to "facebook.com").
How may I fix the issue above?
Any help would be greatly appreciated, I've been working on this for 4 days now, and I need to get it done. Thank you!
XML
PHP Code:
<?xml version='1.0' encoding='ISO-8859-1'?>
<chapter_list>
<chapter>
<name>
Google
</name>
<image>
http://www.google.com/images/google.jpg
</image>
<link>
google.com
</link>
</chapter>
<chapter>
<name>
MSN
</name>
<image>
http://www.msn.com/images/msnlogo.jpg
</image>
<link>
msn.com
</link>
</chapter>
<chapter>
<name>
Yahoo
</name>
<image>
http://www.yahoo.com/images/yahoologo.jpg
</image>
<link>
yahoo.com
</link>
</chapter>
<chapter>
<name>
facebook
</name>
<image>
http://www.facbook.com/images/facebooklogo.jpg
</image>
<link>
facebook.com
</link>
</chapter>
</chapter_list>
Action Script 3
PHP Code:
// [AS3] The code below is to read an XML file //
var myXML:XML;
var myLoader:URLLoader = new URLLoader();
myLoader.load(new URLRequest("data/chapter_list.xml"));
myLoader.addEventListener(Event.COMPLETE, processXML);
function processXML(e:Event):void{
myXML = new XML(e.target.data);
var chapterImage = myXML.chapter.image;
var chapterLink = myXML.chapter.link[i];
for(var i:int = 0; i<myXML.*.length(); i++ ){
// AS3 Create Movie Clip for each XML Entry
var imageArea:MovieClip = new MovieClip();
imageArea.graphics.drawRect(0, 0, 126, 76);
imageArea.graphics.endFill();
imageArea.x = 17 + (i*126);
imageArea.y = 0;
addChild(imageArea);
// AS3 Load External Image Into Movie Clip
var image =new Loader();
image.load(new URLRequest(chapterImage[i]));
imageArea.addChild(image);
// AS3 Movie as Button
imageArea.addEventListener(MouseEvent.CLICK, gotoPage);
}
function gotoPage(e:MouseEvent):void{
navigateToURL(new URLRequest("http://www." + chapterLink), "_blank");
trace(chapterLink);
}
}
I'm not at the scrolling part yet.