错误1120:访问未定义的属性

时间:2012-05-31 02:47:15

标签: 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 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():
    }
  }
}
编辑:我修复了大写错误后突然出现新错误(谢谢杰森)。 任何人都可以帮我这个吗?

1 个答案:

答案 0 :(得分:1)

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;
    }
}