PDA

View Full Version : Controling



TVM_XST
May 28th, 2008, 12:40 AM
I have two SWF .One is Parent.swf and the other is Child.swf.I successfully loaded the Child.swf into the parent.Now I want to control the Child.swf from parent ,using ActionScript. How to do this Please help !

hasch2o
May 28th, 2008, 02:56 AM
If you could post the code with which you loaded the child.swf it would be easier to reply.

But I guess you will have something like


var myLoader:Loader = new Loader();
myLoader.load(new URLRequest("child.swf"));
//(If you post your code, people can give you a reply using your variable names and stuff, it might be less confusing)

then you could use


myLoader.content

to control the properties of your child.swf

TVM_XST
May 29th, 2008, 12:15 AM
this is my code


private var SWFName:String="Child.swf";
private var ldr:Loader= new Loader();

public function Parent()
{

var requ:URLRequest = new URLRequest(SWFName);
ldr.load(requ);

hasch2o
May 29th, 2008, 12:42 AM
Did you have a look at this page:
http://www.kirupa.com/developer/flashcs3/loading_image_as3_pg1.htm

the same thing can be applied to an swf.

in the onComplete event you could attach the swf and start controlling it.
Maybe something like that:



rivate var ldr:Loader;
private var mc:MovieClip;

function loadWhatever(url:String):void {
// Set properties on my Loader object
ldr = new Loader();
ldr.load(new URLRequest(url));
ldr.contentLoaderInfo.addEventListener(Event.COMPL ETE, iAmLoaded);
}

loadWhatever("Child.swf");

function iAmLoaded(e:Event):void {
mc = ldr.content;
Parent.addChild(mc);
//control Child with mc
mc.x = 20;
}