I'm in a Flex Mobile application project. I need to dispatch an event to the FlexGlobals.topLevelApplication and it has to contain a custom message.
I'm trying to make an object and dispatch it like this:
//create the event Object
var receivedObjMsg:Object = new Object();
receivedObjMsg.name = "receivedMessage";
receivedObjMsg.message = messagevarhere;
FlexGlobals.topLevelApplication.dispatchEvent(receivedObjMsg);
and then receive it like this on the other view like this:
FlexGlobals.topLevelApplication.addEventListener("receivedMessage", receiveMsgHandler);
protected function receiveMsgHandler(event:Event):void
{
trace("IT WORKED!");
}
But its saying it cant make an object into an event:
Type Coercion failed: cannot convert Object@5a507911 to flash.events.Event.
I also tried putting this in the bottom of the main application mxml where i created the event;
<fx:Metadata>
[Event(name="receivedMessage", type="flash.events.Event")]
</fx:Metadata>
I can't really seem to find an example that demonstrates what im trying to do. Any ideas how I can get this to work?