Accessing content of loaded swfs

Hello, I’m still relatively new to AS3 and I’m having a bit of a hard time with loaders, and would appreciate some insight.

Basically, I have a.swf which creates a loader that loads b.swf. b.swf is a 1 frame movie. On it’s main timeline there is a movieclip with an instance name of ‘box’. Is there any way a.swf can read/change values of the ‘box’ movie clip in b.swf?

Here is the code I presently have in a.swf…

var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
loader.load(new URLRequest("b.swf"));
addChild(loader);


function completeHandler(event:Event):void {
    trace(event.target.content.box.width)
}

I get the following error when I compile…

ReferenceError: Error #1069: Property box not found on flash.display.AVM1Movie and there is no default value.
at b_fla::MainTimeline/completeHandler()

I’m really not sure what I can do, and would greatly appreciate any help. Thanks!!!

try this:

var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
loader.load(new URLRequest("b.swf"));
addChild(loader);


function completeHandler(event:Event):void {
    var content:* = event.target.content;

    trace(content.box.width)
}

It works, thanks for the help.

I actually realized in my example, I accidentally set the publish settings of b.swf to AS 2.0. After I changed it to AS 3.0 it worked like a charm. D’oh!