Hi I’ve got a custom Thumbnail class that is supposed to be listening for a custom event from another class called WebPage. Here is the code in the WebPage Class:
public static const GO_UP:String = "Go_Up";
private function createThumbs()
{
for(var i:uint = 0; i <xmlDoc.item.length(); i++)
{
var holder:String = xmlDoc.item*.@thumb;
var thumb:ThumbNails = new ThumbNails(i,holder);
addChild(thumb);
}
}
a Sprite in the class has this on it: upWeb.addEventListener(MouseEvent.CLICK, sendUp);
private function sendUp(e:MouseEvent)
{
trace("ok");
dispatchEvent(new Event(GO_UP, true));
}
flash displays ok when I click on it so I know it is getting this far.
In the ThumbNails class I have:
public function ThumbNails(i:uint = 0,s:String = "spence.png")
{
id = i+1;
currentPos = id;
holder = s;
thumb.load(new URLRequest("images/" + holder));
addEventListener(WebPage.GO_UP, moveUp);
thumb.y = id * 100;
addChild(thumb);
}
private function moveUp(e:Event)
{
trace("up");
}
All the variables are correct I believe because the program runs fine without errors, but the moveUp function never gets called. Is it because I am creating the thumb variable in the for loop? Any suggestions? I’ve been attacking this hurdle for a while now. Also sorry if I forgot some code by accident, I’m pretty deep in a project and just thought I would keep the post to a minimum. Thanks!