Actionscript 3 错误1120:访问未定义的属性
我收到了一个访问未定义属性的错误,该错误来自于我所加星号的行上的以下代码,尽管我已经在类中进一步定义了该函数:Actionscript 3 错误1120:访问未定义的属性,actionscript-3,flash-cs5,Actionscript 3,Flash Cs5,我收到了一个访问未定义属性的错误,该错误来自于我所加星号的行上的以下代码,尽管我已经在类中进一步定义了该函数: package { import flash.display.Stage; import flash.events.Event; import flash.events.KeyboardEvent; public class Key{ private static var initialized:Boolean = false; private sta
package {
import flash.display.Stage;
import flash.events.Event;
import flash.events.KeyboardEvent;
public class Key{
private static var initialized:Boolean = false;
private static var keysDown:Object = new Object();
private function initialize(stage:Stage){
if(!initialized){
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyPressed);
stage.addEventListener(KeyboardEvent.KEY_UP, keyReleased);
**stage.addEventListener(Event.DEACTIVATE, clearKeys);**
initialized = true;
}
}
public static function isDown(keyCode:uint):Boolean {
return Boolean(keyCode in keysDown);
}
Private static function keyPressed(event:KeyboardEvent):void {
keysDown[event.keyCode] = true;
}
private static function keyReleased(event:KeyboardEvent):void{
if(event.keyCode in keysDown){
delete keysDown[event.keyCode];
}
}
Private static function clearkeys(event:Event):void{
keysDown = new Object():
}
}
}
编辑:新的错误弹出后,我已经修复了上限错误(谢谢杰森)。
有人能帮我吗?
Private
必须是小写才能作为访问修饰符关键字Private
例如:
private static var initialized:Boolean = false;
作为大写的Private
编译器假定您引用的是名称空间“Private”,例如:
package
{
import flash.utils.flash_proxy;
import mx.core.mx_internal;
use namespace arcane;
public dynamic class X
{
flash_proxy var prop1:Boolean;
mx_internal var prop2:Boolean;
arcane var prop3:Boolean;
}
}
将
Private
更改为Private
。您的调用处理程序clearKeys
,函数本身使用所有小写clearKeys