Trying to drag objects, having trouble using Input.as

Discuss issues specific to the Flash/AS3 port of Box2D
badfitz100
Posts: 3
Joined: Mon Aug 10, 2015 6:33 am

Trying to drag objects, having trouble using Input.as

Postby badfitz100 » Mon Aug 10, 2015 6:36 am

when I try and run, I get this error:

[Fault] exception, information=TypeError: Error #1009: Cannot access a property or method of a null object reference.

at this line:

Code: Select all

         return (keyState[k] == 1);


which is in this function:

Code: Select all

      static public function isKeyPressed(k:int):Boolean{
         timeSinceLastKey = 0;
         return (keyState[k] == 1);
      }

in my other class, I call isKeyPressed from this:

Code: Select all

      public function MouseDestroy():void{
         // mouse press
         if (!Input.mouseDown && Input.isKeyPressed(68/*D*/)){
            
            var body:b2Body = GetBodyAtMouse(true);
            
            if (body)
            {
               world.DestroyBody(body);
               return;
            }
         }
      }

Return to “Flash”



Who is online

Users browsing this forum: No registered users and 2 guests