我在Flex Mobile应用程序项目中。我需要将事件分派给FlexGlobals.topLevelApplication,并且它必须包含一条自定义消息。自定义Flash/Flex事件对象
我试图让一个对象,并派遣这样说:
//create the event Object
var receivedObjMsg:Object = new Object();
receivedObjMsg.name = "receivedMessage";
receivedObjMsg.message = messagevarhere;
FlexGlobals.topLevelApplication.dispatchEvent(receivedObjMsg);
,然后接受它像这样在这样的另一种观点:
FlexGlobals.topLevelApplication.addEventListener("receivedMessage", receiveMsgHandler);
protected function receiveMsgHandler(event:Event):void
{
trace("IT WORKED!");
}
但它说它不能使对象到事件:
Type Coercion failed: cannot convert [email protected] to flash.events.Event.
我也试图把这个主APPLICAT底部离子mxml在哪里我创建的事件;
<fx:Metadata>
[Event(name="receivedMessage", type="flash.events.Event")]
</fx:Metadata>
我真的不能找到一个示例来说明我在做什么。任何想法如何让这个工作?
我知道我看到它在某个地方,但我不记得我在哪里看过它,对不起! – brybam