[FONT=Arial]For instance in the below code a parent can control the SWF child’s function “alert ()”.[/FONT]
[FONT=Arial]But how a SWF child can control parent’s function “ReceivingChildMsg()” ?[/FONT]
[COLOR=blue][FONT=Arial]public class ChildSWF extends Sprite [/FONT][/COLOR]
[COLOR=blue][FONT=Arial]{[/FONT][/COLOR]
[COLOR=blue][FONT=Arial] private var t:TextField;[/FONT][/COLOR]
[COLOR=blue][FONT=Arial] public function ChildSWF():void [/FONT][/COLOR]
[COLOR=blue][FONT=Arial] {[/FONT][/COLOR]
[COLOR=blue][FONT=Arial] t = new TextField( );[/FONT][/COLOR]
[COLOR=blue][FONT=Arial] t.text = “No Message from the Parent”;[/FONT][/COLOR]
[COLOR=blue][FONT=Arial] addChild( t );[/FONT][/COLOR]
[COLOR=blue][FONT=Arial] //~~~~~~~~~~[/FONT][/COLOR]
[COLOR=blue][FONT=Arial] Button.addEventListener(MouseEvent.CLICK,clickHandler,false,0,true);[/FONT][/COLOR]
[COLOR=blue][FONT=Arial] }[/FONT][/COLOR]
[COLOR=blue][FONT=Arial] public function alert(msg:String):void [/FONT][/COLOR]
[COLOR=blue][FONT=Arial] {[/FONT][/COLOR]
[COLOR=blue][FONT=Arial] t.text = msg;[/FONT][/COLOR]
[COLOR=blue][FONT=Arial] }[/FONT][/COLOR]
[COLOR=blue][FONT=Arial] protected function clickHandler(event:MouseEvent):void[/FONT][/COLOR]
[COLOR=blue][FONT=Arial] {[/FONT][/COLOR]
[COLOR=blue][FONT=Arial] ReceivingChildMsg (‘Received Child Message’);[/FONT][/COLOR]
[COLOR=blue][FONT=Arial] }[/FONT][/COLOR]
[COLOR=blue][FONT=Arial]########[/FONT][/COLOR]
[COLOR=blue][FONT=Arial]public class ParentSWF extends Sprite [/FONT][/COLOR]
[COLOR=blue][FONT=Arial]{[/FONT][/COLOR]
[COLOR=blue][FONT=Arial] private var loader:Loader;[/FONT][/COLOR]
[COLOR=blue][FONT=Arial] public function ParentSWF():void [/FONT][/COLOR]
[COLOR=blue][FONT=Arial] {[/FONT][/COLOR]
[COLOR=blue][FONT=Arial] loader = new Loader();[/FONT][/COLOR]
[COLOR=blue][FONT=Arial] loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadComplete);[/FONT][/COLOR]
[COLOR=blue][FONT=Arial] loader.load(new URLRequest(‘ChildSWF.swf’));[/FONT][/COLOR]
[COLOR=blue][FONT=Arial] //~~~~~~~~~~~[/FONT][/COLOR]
[COLOR=blue][FONT=Arial] tc = new TextField( );[/FONT][/COLOR]
[COLOR=blue][FONT=Arial] tc.text = “No Message from the Child”;[/FONT][/COLOR]
[COLOR=blue][FONT=Arial] addChild( tc );[/FONT][/COLOR]
[COLOR=blue][FONT=Arial] }[/FONT][/COLOR]
[COLOR=blue][FONT=Arial] private function onLoadComplete(e:Event):void [/FONT][/COLOR]
[COLOR=blue][FONT=Arial] {[/FONT][/COLOR]
[COLOR=blue][FONT=Arial] var loaderInfo:LoaderInfo = e.target as LoaderInfo;[/FONT][/COLOR]
[COLOR=blue][FONT=Arial] addChild(e.target.content);[/FONT][/COLOR]
[COLOR=blue][FONT=Arial] var swf:Object = loaderInfo.content;[/FONT][/COLOR]
[COLOR=blue][FONT=Arial] swf.x = 75;[/FONT][/COLOR]
[COLOR=blue][FONT=Arial] swf.y = 50;[/FONT][/COLOR]
[COLOR=blue][FONT=Arial] swf.alert(‘Received Parent Message’);[/FONT][/COLOR]
[COLOR=blue][FONT=Arial] }[/FONT][/COLOR]
[COLOR=blue][FONT=Arial] public function ReceivingChildMsg ( var childsMsg:String):void[/FONT][/COLOR]
[COLOR=blue][FONT=Arial] {[/FONT][/COLOR]
[COLOR=blue][FONT=Arial] tc.text = childsMsg;[/FONT][/COLOR]
[COLOR=blue][FONT=Arial] }[/FONT][/COLOR]
[COLOR=blue][FONT=Arial]}[/FONT][/COLOR]