0

我找不到是否有一种方法可以定义一个变量,该变量可以使用 Flash CS5.5 从 Actionscript 3.0 项目中的任何位置访问。

我试过这个:

_global.myScore = 0;

我从adobe_website得到的,但它没有用。

任何人都可以提供帮助或提供任何线索吗?

编辑:我只是尝试了最简单的方法,看起来它正在工作,但我不确定。我刚刚创建了一个新层,并在第一帧中定义了变量:

var myvar:int=0;

这种方式正确吗?

4

1 回答 1

0

Try static variable, declared in some class:

public static myScore:int = 0;

use:

SomeClass.myscore += 1;

but be careful not to use them too much or too often - in terms of optimization, they are not so good.

Static members are members of the class, not the instance, and you can't use them within regular function - the function has to be static too.

于 2013-11-28T17:18:38.973 回答