Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/flash/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在flash actionscript中将可变值从一层传递到另一层?_Flash_Actionscript - Fatal编程技术网

如何在flash actionscript中将可变值从一层传递到另一层?

如何在flash actionscript中将可变值从一层传递到另一层?,flash,actionscript,Flash,Actionscript,您好,下面是我的项目的图片,您可以看到第25帧的骰子层,在第25帧有一个可变值,我需要将其传递给JS层第一帧,这是滚动层的另一层,请执行所需操作。您可以执行: 骰子/第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

您好,下面是我的项目的图片,您可以看到第25帧的骰子层,在第25帧有一个可变值,我需要将其传递给JS层第一帧,这是滚动层的另一层,请执行所需操作。

您可以执行:

骰子/第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'   
// 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

}
JS/frame 1:

// 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'   
// 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

}

层与变量完全无关,但帧却如此。如果在第一帧中创建变量,则可以在所有后续帧中读取/写入(不考虑层)。在这里,我尝试根据骰子滚动帧25移动棋子,随机生成的数字位于一个称为骰子层的层中,而棋子移动位于另一层,即,。命名为层JS第1帧,但每次掷骰子后,棋子都会归零,这意味着它会重置…@Kogile你想在JS/第1帧中重置它吗?