Problem: There is an mxml application and it loads an other (external) swf (mxml) application. How can I dispatch an event form the loaded app to the main app?
Solution:
Loaded.mxml:
This function is binded to a button click in my example:
private function sendevent(event:MouseEvent):void
{
this.parent.dispatchEvent(new Event("clicked"));
}
Main.mxml:
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
public var loadedSM:SystemManager;
private function loadComplete(event:Event):void
{
loadedSM = SystemManager(loaded.content);
loadedSM.addEventListener(FlexEvent.APPLICATION_COMPLETE, loadedAppComplete);
}
private function loadedAppComplete(event:Event):void
{
loadedSM.addEventListener("clicked", clickhandler);
}
private function clickhandler(event:Event):void
{
Alert.show("Voila!", "yess");
}
]]>
</mx:Script>
<mx:SWFLoader x="10" y="40" source="Loaded.swf" width="206" height="126" id="loaded"
complete="loadComplete(event)"/>
</mx:Application>
2008. szeptember 23., kedd
Feliratkozás:
Bejegyzések (Atom)