views:

999

answers:

2

Assume I have 2 swf.

first one I have a method on the first frame

function methodA():void { }

Second one will use the loader class to load the first one and use that to call the methodA.

I wonder is it possible to do that... What about passing data....

I am abit too poor in AS 3.0 , I can pass the variable and call function from external swf but how do pass the value or methods from external child to parent.... coz i want to have clicked on the external swf and add to parent swf

A: 

yes, once a movie clip has loaded another movie clip they can talk to each other just like any parent/child movie clip. You will also need to be careful how you use _root in the child movie clip since _root will now point to the parent. There is a way to lock it down so that _root points to the root of the individual swf, even when it is loaded into a broader context, but I can't recall exactly how that's done... someething like lockroot = true or some such, but you'll need to look it up.

Edit: sorry, didn't see the AS3 specific aspect of the question. Have never looked at AS3 (haven't touched Flash in a couple of years), so, have no idea what they've done in this version.

Dr.Dredel
The question is as3 specific so the _root info is invalid.
James Hay
+1  A: 

As Dr.Dredel said, once you load an external swf you can get a reference to your loaded swf and call methods, add listeners, pass data, just as you would with any other object in your code.

For example:

var myLoader:Loader = new Loader(); 
var url:URLRequest = new URLRequest("myExternalMovie.swf"); 
myLoader.load(url);
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, function(event : Event)
{
    var contenet : MovieClip = event.target.content;
    content.addEventListener(yourEvent.SOMETHING_COMPLETE, yourEventHandler);
    content.property = "someString";
    content.someMethod();

});
James Hay