Okay I wrote this code for my class project assignment, now I have to modify it so I have a next button which works fine but I need to modify it so that I have a previous button that will click backwards through the array.
Here is my code any help would be appreciated!
Thanks!
// start code here is the code
stop();
var pepsiArray: Array = [“pepsi_images/1_PEPSI.jpg”,
“pepsi_images/2_PEPSI.jpg”,
“pepsi_images/3_PEPSI.jpg”,
“pepsi_images/4_PEPSI.jpg”,
“pepsi_images/5_PEPSI.jpg”,
“pepsi_images/6_PEPSI.jpg”];
var count = 0;
var imageLoader: Loader = new Loader();
addChild(imageLoader);
var imageRequest: URLRequest = new URLRequest(pepsiArray[count]);
imageLoader.x = 0;
imageLoader.y = 0;
imageLoader.load(imageRequest);
function imageLoad(pEvent:MouseEvent):void{
++count;
if (count == pepsiArray.length)
{
count = pepsiArray.length-1;
}
else
{
imageLoader.unload();
imageRequest.url = pepsiArray[count];
imageLoader.x = 0;
imageLoader.x = 0;
imageLoader.load(imageRequest);
}
}
btn_next.addEventListener(MouseEvent.CLICK, imageLoad);
// end code here