Hi all,
I found this great tutorial here in kirupa how to create image gallery using XML http://www.kirupa.com/developer/mx2004/xml_flash_photogallery.htm
How to do the same just with AS3?
I already have my XML loaded, I just don’t know how to load images in sequence from XML using previous and next buttons
my XML:
<?xml version="1.0" encoding="UTF-8"?>
<gallery>
<image>
<title>Head full of Sand</title>
<url>images/float_head.jpg</url>
</image>
<image>
<title>Neck Cramp</title>
<url>images/neck_cramp.jpg</url>
</image>
<image>
<title>This is Cool</title>
<url>images/gaine.jpg</url>
</image>
</gallery>
and AS (galleryData is XML):
var loader:Loader = new Loader();
var preloader:MovieClip = new Pro();
preloader.x = stage.stageWidth/2;
preloader.y = stage.stageHeight/2;
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgress);
next_btn.buttonMode = prev_btn.buttonMode =true;
next_btn.addEventListener(MouseEvent.CLICK, onClick);
prev_btn.addEventListener(MouseEvent.CLICK, onClick);
var file_path:String = galleryData.image.url.text();
var imgNum:int = galleryData.image.length();
function onClick(e:MouseEvent):void {
switch (e.currentTarget) {
case next_btn :
// LOAD NEXT IMAGE
break;
case prev_btn :
// LOAD PREVIOUS IMAGE
break;
}
}
function loadComplete(e:Event):void {
removeChild(preloader);
addChild(loader);
description.text = galleryData.image[1].title.text();
}
function onProgress(e:Event):void {
addChild(preloader);
}
I guess I need to use some kind of loop to through array of XML elements.
Thank you!