Listing 1

private function goNext():void {
if (currentIndex != pictures.length){
currentIndex++;
}
else {
currentIndex = 0;
}
//set the current picture
currentPicture = pictures[currentIndex];
}
private function goPrevious():void {
if (currentIndex != 0){
currentIndex--;
}
else {
currentIndex = pictures.length;
}
currentPicture = pictures[currentIndex];
}
public function set dataProvider(value:Array):void {
pictures = value;
currentIndex = 0;
currentPicture = pictures[currentIndex];
}


Listing 2

//public setter for xmlSource. Typically called by xmlReceived when the xml file
// has been loaded, but it can be used to set the xml directly
public function set xmlSource(xml:XML):void{
var index:int = 0;
var pictures:Array = new Array();
for each( var image:XML in xml..image ) {
pictures[index] = new PhotoshowImage();
pictures[index].name = image.itemName;
pictures[index].caption = image.itemCaption;
pictures[index].width = image.itemWidth;
pictures[index].height = image.itemHeight;
index++;
}
photoshowContainer.dataProvider = pictures;
}