PDA

View Full Version : Accessing content of loaded swfs



mofakiii
July 10th, 2008, 06:17 PM
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.CO MPLETE, 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!!!!

tpspoons
July 10th, 2008, 07:04 PM
try this:


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


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

trace(content.box.width)
}

mofakiii
July 10th, 2008, 07:15 PM
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!