How a SWF Child can control a Parent’s function / variable ?

  • Blue_Crystal
  • Born
  • Born
  • Blue_Crystal
  • Posts: 1

Post 3+ Months Ago

For instance, in the below code a parent can control the SWF child’s function “alert ()”.

But how a SWF child can control the parent’s function “ReceivingChildMsg()” ?

( Note: I am using Actionscript 3 )

public class ChildSWF extends Sprite
{
private var t:TextField;

public function ChildSWF():void
{
t = new TextField( );
t.text = "No Message from the Parent";
addChild( t );
//~~~~~~~~~~
Button.addEventListener(MouseEvent.CLICK,clickHandler,false,0,true);
}

public function alert(msg:String):void
{
t.text = msg;
}

protected function clickHandler(event:MouseEvent):void
{
ReceivingChildMsg (‘Received Child Message’);
}



########

public class ParentSWF extends Sprite
{
private var loader:Loader;

public function ParentSWF():void
{
loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadComplete);
loader.load(new URLRequest('ChildSWF.swf'));

//~~~~~~~~~~~
tc = new TextField( );
tc.text = "No Message from the Child";
addChild( tc );

}
private function onLoadComplete(e:Event):void
{
var loaderInfo:LoaderInfo = e.target as LoaderInfo;

addChild(e.target.content);

var swf:Object = loaderInfo.content;

swf.x = 75;
swf.y = 50;

swf.alert('Received Parent Message');
}

public function ReceivingChildMsg ( var childsMsg:String):void
{
tc.text = childsMsg;
}

}
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

Post Information

  • Total Posts in this topic: 1 post
  • Users browsing this forum: No registered users and 10 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.