Hank Turtle Lo
Hank Turtle Lo

Reputation: 3

Error 1120:Access of undefined property

I am receiving an error of access of undefined property from the following code on the line which i've starred, even though i have already defined the function further in the class:

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():
    }
  }
}

EDIT:New error popping up after I have fixed the caps error (Thank you Jason). Can anyone help me with this?

Upvotes: 0

Views: 1860

Answers (1)

Jason Sturges
Jason Sturges

Reputation: 15955

Private must be lowercase to be the access modifier keyword private.

As in:

private static var initialized:Boolean = false;

As upper case Private the compiler assumes you are referencing namespace "Private", such as:

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

Upvotes: 1

Related Questions