【发布时间】:2011-05-23 12:27:11
【问题描述】:
我正在通过扩展 flash.display.SimpleButton 在 ActionScript 中创建一个按钮
但是,当我在构造函数中声明某些变量时,按钮的行为与预期不同,这些变量也恰好作为属性存在于 SimpleButton 类中。他们似乎有冲突..
这是为什么?不应该允许本地声明的变量与类似命名的类属性共存吗?
下面的片段可能更好地说明了这个问题:
public class MyButton extends SimpleButton{
public function MyButton(/*..*/){
var upState:ButtonDisplayState = new ButtonDisplayState(/*..*/));
var downState:ButtonDisplayState = new ButtonDisplayState(/*..*/);
var overState:ButtonDisplayState = new ButtonDisplayState(/*..*/);
var hitTestState:ButtonDisplayState = new ButtonDisplayState(/*..*/);
super(upState, overState, downState, hitTestState);
}
}
API 文档在这里(例如查找 upState):http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/SimpleButton.html#upState
谢谢,
哎呀。
【问题讨论】:
-
只是为了澄清,将变量重命名为例如up、down、hit 等有效,但我很好奇为什么会发生这种情况?
标签: object actionscript orientation scope