hello
I have two widgets : W1 and W2
I would like to send data from w1 to w2 with a custom event
when i receive the object from w1 I can't transform it into my own class (MyClassEvent). however object type is right because in debug mode Eclipse display its type (MyClassEvent)
e.g :
//
// MyClassEvent
//
public class MyClassEvent extends Event
{
public static const GOTO_POINT:String="gotopoint";
public var drawEvent:DrawEvent;
public function MyClassEvent(type:String, event:DrawEvent)
{
super(type, false, false);
this.drawEvent=event;
}
}
//
// W1 sender
//
private function sender_clickhandler() : void {
var id:Number=ViewerContainer.getInstance().widgetManager.getWidgetId("w1");
var widget:IBaseWidget =ViewerContainer.getInstance().widgetManager.getWidget(id,true) ;
if (widget !=null) {
var mp:MapPoint=map.toMapFromStage(550, 480);
widget.dispatchEvent(new MyClassEvent(MyClassEvent.GOTO_POINT,new DrawEvent(Geometry.MAPPOINT,new Graphic(mp))));
}
}
//
// W2 listener
//
private function init():void {
addEventListener(MyClassEvent.GOTO_POINT,function event(event:Event):void {
var mce:MyClassEvent = MyClassEvent (event);
// At this point, mce is null but event parameter is well displayed by
// Eclispse's debugger (not null and with the good type !)
trace(mce.drawEvent);
});
}
Nicolas