Hi,
This is the approach i was trying to explain in the previous email.
It was just so your VO doest have to extend EventDispatcher.
Not sure why your getting an id error though.. Perhaps stepping through
the code with the debugger will help.
phipzkillah wrote:
> Ok.
>
> I partly have this working. Is this the right (or a valid) approach?
>
I imagine that will depend on whom you ask? :)
> Main.mxml
>
> //init
> globalVO.addEventListener("globalChangeEvent",
> globalChangeEventHandler);
>
> private function globalChangeEventHandler(event:GlobalChangeEvent):void{
> Alert.show("I heard a global change :)");
> }
>
> GlobalVO.as
> //instance var
> private var _evtDispatcher:EventDispatcher;
>
> //custom add event listener
> public function addEventListener(evt:String, callBack:Function):void{
> this._evtDispatcher.addEventListener(evt, callBack);
> }
>
> //dispatches event
> private function dispatchChangeEvent():void{
> var eventObj:GlobalChangeEvent = new GlobalChangeEvent(this,
> "globalChangeEvent");
> this._customEvtDispatcher.dispatchEvent(eventObj);
> }
I notice that one is called _evtDispatcher and the other
_customEvtDispatcher, not sure if thats the real code or not though or
just example code.
>
>
> This will give me the following error BUT the event is dispatched and my
> main.mxml hears it.
>
> ReferenceError: Error #1069: Property id not found on
> flash.events.EventDispatcher and there is no default value.
> at main/::globalChangeEventHandler()
> at
> flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEven\
> tFunction()
> at flash.events::EventDispatcher/dispatchEvent()
> at com.minowireless.reports.vo::GlobalVO/::dispatchChangeEvent()
> at com.minowireless.reports.vo::GlobalVO/set startDate()
> at main/::dispatchDate()
> at main/__startDate1_change()
> at
> flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEven\
> tFunction()
> at flash.events::EventDispatcher/dispatchEvent()
> at mx.core::UIComponent/dispatchEvent()
> at mx.controls::DateField/::dropdown_changeHandler()
> at
> flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEven\
> tFunction()
> at flash.events::EventDispatcher/dispatchEvent()
> at mx.core::UIComponent/dispatchEvent()
> at mx.controls::DateChooser/::dateGrid_changeHandler()
> at
> flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEven\
> tFunction()
> at flash.events::EventDispatcher/dispatchEvent()
> at mx.core::UIComponent/dispatchEvent()
> at mx.controls::CalendarLayout/::dispatchChangeEvent()
> at mx.controls::CalendarLayout/::mouseUpHandler()
>
>
>
regards,
-- shaun