# Cant figure out the Event Dispatcher

**URL:** <https://forum.kirupa.com/t/cant-figure-out-the-event-dispatcher/309637>\
**Category:** flash\
**Created:** [May 20, 2010, 12:45pm UTC](https://forum.kirupa.com/t/cant-figure-out-the-event-dispatcher/309637 "2010-05-20T12:45:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rez1n](https://avatars.discourse-cdn.com/v4/letter/r/f9ae1b/32.png) [@rez1n](https://forum.kirupa.com/u/rez1n)\
**Post date:** [May 20, 2010, 12:45pm UTC](https://forum.kirupa.com/t/cant-figure-out-the-event-dispatcher/309637/1 "2010-05-20T12:45:54Z")

</div>

Hey Guys, I wonder if you can help. Maybe im going about this all wrong. I have coded a navigation class to work with movieclip on the stage. when the user clicks it needs to tell the main website class, im trying to figure out how to do this using Events but i cant seem to figure it out.

Maybe you can check it out and give me a helpfull nudge…

heres the code:

com.website.as:  
package com {  
import flash.display._;  
import flash.events._;  
import com.webEvent  
import com.navigation  
public class website extends MovieClip {

public var webevent:webEvent = new webEvent()  
public var nav : navigation

public function website():void {  
init();  
}  
public function init():void {  
webevent.addEventListener(webEvent.PAGE\_CHANGED, onPageChange)  
loadthemovies()  
}  
private function onPageChange(event:Event) {  
trace (“event:”+event.target)  
}  
}

com.webEvent.as:  
package com{  
import flash.events.\*

public class webEvent extends EventDispatcher {  
private var \_page:Number = 0  
public static const PAGE\_CHANGED:String = “pageChanged”

public function set page(newPage:Number):void {  
trace (“page:”+newPage) // This trace works!  
\_page = newPage  
dispatchEvent(new Event(PAGE\_CHANGED))  
}  
public function get page():Number {  
return \_page  
}  
}  
}

com.navigation.as:  
package com {  
import flash.display._;  
import flash.events._  
import com.webEvent  
public class navigation extends MovieClip {  
public var evt:webEvent = new webEvent()

public function navigation():void {  
evt.page = 20  
}  
// I also have MOUSE\_UP event code for navigation that changes the evt.page variable.  
}  
}

Any help would be appreciated! 😏
