开发者

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

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开发者_如何学Python 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!


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜