如何将变量值从flash actionscript中的一个层传递到另一个层?

时间:2014-12-08 13:01:42

标签: flash actionscript

     ,

你好下面是我的项目的图像,你可以看到第25帧和第25帧的骰子层有一个变量值,我需要将它传递给JS层第一帧,这是另一层下来的卷层请做需要的。

1 个答案:

答案 0 :(得分:0)

你可以这样做:

骰子/第25帧:

// here the String type is just for example of course, set the type of your var
// the shared_var var is global, so you can use it in any frame of any layer
var shared_var:String = 'data'   

JS /第1帧:

// we have to verify if shared_var is defined and not null 
// because in the first iteration of your animation, shared_var does not exist yet because it's defined in the frame 25 
if(shared_var){

    // here trace is just for example, you do what you want with your var
    trace(shared_var)  // gives : data

}