Skip to main content
Participating Frequently
February 17, 2011
Answered

Need to stop a counter

  • February 17, 2011
  • 2 replies
  • 611 views

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)

}

This topic has been closed for replies.
Correct answer kglad

hmm, same problem with <=

//egypt loader objects//

var myrequest:URLRequest = new URLRequest("jpegs/egypt1.jpg")

var myloader:Loader = new Loader();

var counter:Number=1

var total:int=3;

//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);

if(counter<=total){

myrequest.url="jpegs/egypt"+counter+".jpg"

myloader.load(myrequest)

}


that's not the code i suggested.  use the following.  check it and recheck it to see where you're NOT copying my code.  :

//egypt loader objects//

var myrequest:URLRequest = new URLRequest("jpegs/egypt1.jpg")

var myloader:Loader = new Loader();

var counter:Number=1

var total:int=3;

//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;

if(counter<=total){

myrequest.url="jpegs/egypt"+counter+".jpg"

myloader.load(myrequest)

}

}

2 replies

kglad
Community Expert
Community Expert
February 17, 2011

use:


//egypt loader objects//

var myrequest:URLRequest = new URLRequest("jpegs/egypt1.jpg")

var myloader:Loader = new Loader();

var counter:Number=1

var total:int=3;

//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;

if(counter<=total){

myrequest.url="jpegs/egypt"+counter+".jpg"

myloader.load(myrequest)

}

}

ssteimAuthor
Participating Frequently
February 17, 2011

When I click on the 3rd image, I'm getting the same error message: Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL Not Found. Just to be sure, I'm pasting the current code:

//egypt loader objects//

var myrequest:URLRequest = new URLRequest("jpegs/egypt1.jpg")

var myloader:Loader = new Loader();

var counter:Number=1

var total:int=3;

//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);

if(counter<total){

myrequest.url="jpegs/egypt"+counter+".jpg"

myloader.load(myrequest)

}

}

kglad
Community Expert
Community Expert
February 17, 2011

copy and paste the code i suggested.

kglad
Community Expert
Community Expert
February 17, 2011

what do you expect when you click the last image?  or, what do you want to occur when you click the last image?

ssteimAuthor
Participating Frequently
February 17, 2011

I'd like the final image to stay on screen. I have two other galleries on different tabs, so I'm planning to remove the other two loaders whenever someone is clicked on each tab.