# Dispatch Event help

**URL:** <https://forum.kirupa.com/t/dispatch-event-help/295248>\
**Category:** flash\
**Created:** [August 27, 2009, 6:38am UTC](https://forum.kirupa.com/t/dispatch-event-help/295248 "2009-08-27T06:38:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![brnt7342](https://avatars.discourse-cdn.com/v4/letter/b/b5ac83/32.png) [@brnt7342](https://forum.kirupa.com/u/brnt7342)\
**Post date:** [August 27, 2009, 6:38am UTC](https://forum.kirupa.com/t/dispatch-event-help/295248/1 "2009-08-27T06:38:37Z")

</div>

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:

```auto
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);

```auto
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:

```auto
	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!
