Need to stop a counter
I'm building a image gallery that loads photos from a folder on my computer. There are three images in the folder. Everything works until you click the last image - then a I get the following error message: "Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL Not Found."
Below is my code. I believe that all I need to do is add an event listener to remove the counter object once the third picture is reached, but I'm having trouble figuring out the correct code. Any suggestions would be most appreciated!
//egypt loader objects//
var myrequest:URLRequest = new URLRequest("jpegs/egypt1.jpg")
var myloader:Loader = new Loader();
var counter:Number=1
//egypt gallery//
egypt_mc.addEventListener(MouseEvent.CLICK, cover1);
function cover1 (e:MouseEvent):void{
object1_mc.x=414.15;
object1_mc.y=101.35;
object2_mc.x=520;
object2_mc.y=60;
object3_mc.x=630;
object3_mc.y=60;
stage.addChild(myloader);
myloader.x = 28;
myloader.y = 175;
myloader.load(myrequest)
}
myloader.addEventListener(MouseEvent.CLICK, shownextpicture)
function shownextpicture(e:MouseEvent):void{
counter = counter + 1;
myrequest.url="jpegs/egypt"+counter+".jpg"
myloader.load(myrequest)
}