Im trying to create a simple image gallery with mouseevent . If you click, the image should go next. Right now im loading it from xml, xml and everything else works. i think its the nextImage function is causing the issue.
Heres my code,
package {
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.events.Event;
import flash.display.Loader;
import flash.display.LoaderInfo;
import flash.net.URLRequest;
import flash.net.URLLoader;
import flash.xml.*;
import flash.display.Sprite;
public class main extends MovieClip {
var my_total:Number;
var my_images:XMLList;
var my_loaders_array:Array=[];
var my_success_counter:Number=0;
var my_playback_counter:Number=0;
var my_image_slides:Sprite = new Sprite();
var my_xml_loader:URLLoader = new URLLoader();
public function main() {
// constructor code
rightarrow.buttonMode = true;
leftarrow.buttonMode = true;
rightarrow.addEventListener(MouseEvent.CLICK, rotateright);
//leftarrow.addEventListener(MouseEvent.CLICK, rotateleft);
my_xml_loader.load(new URLRequest("rotation.xml"));
my_xml_loader.addEventListener(Event.COMPLETE, processXML);
}
function processXML(e:Event):void {
var xmlData:XML = new XML(e.target.data);
trace("xml is working "+ xmlData.(@id=="BLACK").IMAGE.@file);
//myTotal = xmlData.(@id=="BLACK".IMAGE.length());
/*for each( var shoe in xmlData.(@id=="BLACK").IMAGE){
shoesApath.push(shoe.@file);
}*/
my_images=xmlData.(@id=="BLACK").IMAGE.@file;
my_total=my_images.length();
loadImages();
//xmlData.removeEventListener(Event.COMPLETE, LoadXML);
}
public function rotateright(e:MouseEvent):void{
//loadImages();
nextImage();
}
/*public function rotateleft(e:MouseEvent):void{
for(var i:int=0; i<shoesA.length; i--){
imageloader.addChild(shoesApath*);
}
}*/
public function loadImages(){
for (var i:Number = 0; i < my_total; i++) {
var my_url:String = my_images*;
var my_loader:Loader = new Loader();
my_loader.load(new URLRequest(my_url));
my_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
my_loaders_array.push(my_loader);
}
}
public function onComplete(e:Event):void{
var my_loaderInfo:LoaderInfo=LoaderInfo(e.target);
trace("my total is " +my_total);
my_playback_counter++;
if (my_playback_counter==my_total) {
my_playback_counter=0;
}
nextImage();
//my_loaderInfo.removeEventListener(Event.COMPLETE, onComplete);
}
public function nextImage():void{
//var my_img:Loader = Loader(shoesApath[counter]);
var my_image:Loader=Loader(my_loaders_array[my_playback_counter]);
trace("the count is " + my_playback_counter);
my_image_slides.addChild(my_image);
imageholder.addChild(my_image_slides);
my_image.x = (stage.stageWidth - my_image.width)/2;
my_image.y = (stage.stageHeight - my_image.height)/2;
//my_tweens_array[0]=new Tween(my_image,"alpha",Strong.easeOut,0,1,1,true);
}
}
}