我有一個Flex應用程序裏子調度父母內部的事件:如何以更加動作友好的方式傾聽事件?
孩子:
<fx:Metadata>
[Event(name="myEvent", type="flash.events.Event")]
</fx:Metadata>
<fx:Script>
<![CDATA[
dispatchEvent(new Event("myEvent"));
]]>
</fx:Script>
父:
<comp:poppy id="myPopup" myEvent="myEventStuff(event);" />
我已經改變了我的代碼,以便創建myChild在actionscript中,而不是如圖所示的mxml標籤。如何在actionscript中添加事件偵聽器?你可以這樣做
public function showPoppy(evt:MouseEvent):void {
var myPopup:poppy = PopUpManager.createPopUp(this, poppy, true) as poppy;
PopUpManager.centerPopUp(myPopup:poppy);
myPopup:poppy.includeInLayout = true;
myPopup:poppy.visible = true;
// how do I add the event listener?
}