AS2 movie inside AS3 movie can't access flashvars... or any parent movie vars

646 views Asked by At

Not my code, trying to fix it at the 11th hour.

Trying to access flashvars from a legacy AS2 movie loaded inside an AS3 movie

The AS3 movie uses com.gskinner.utils.SWFBridgeAS3 for AS2 compatibility.

The flashvars defined in the html file are not accessible in the AS2 movie. Not as "just variables" (old AS2 flashvars method) nor as the

stage.loaderinfo.parameters 

which AS3 would provide.

Nothing seems to work, even accessing any variable defined in the parent AS3 movie.

So, in the AS3 movie:

var myvar = 5;

in the AS2 movie:

trace(myvar); => undefined
trace(parent.myvar); => undefined

How can I work around this?

Thank you!

2

There are 2 answers

1
Chris On BEST ANSWER

Using the information available on the SWFBridge site, you should do the following:

// in the AS2 SWF:
var myBridge:SWFBridgeAS2 = new SWFBridgeAS2("123456", clientObj);


// in the AS3 SWF:
var myBridge:SWFBridgeAS3 = new SWFBridgeAS3("123456", clientObj);

The ID 123456 can be any unique ID you would like to use.

Then, in the AS3 version:

var myvar = 5;
myBridge.send("updateVar", myvar);

In the AS2 version, have the following method:

function updateVar(var) {
    trace(var); // will output 5
}

Reference: http://gskinner.com/blog/archives/2007/07/swfbridge_easie.html

1
alxx On

If you have working connection with as2 movie via SWFBridge, just pass those flashvars through it.