Hello, I’m using Senoculars KeyObject Library which can be found here under Actionscript 3.0, com, senocular, util, KeyObject.as - http://www.senocular.com/flash/actionscript/ to make life easier with keyboard press functions. However after accessing the KeyObject class I keep getting the error down below. Is there a problem with accessing stage in flash builder? Here’s the part of my code which links to the KeyObject as well as the part causing problems. Please help!! Thanks.
Error Message:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at com.senocular.utils::KeyObject/construct()[C:\Users\Alistair\Adobe Flash Builder 4\Senocular\src\com\senocular\utils\KeyObject.as:29]
at com.senocular.utils::KeyObject()[C:\Users\Alistair\Adobe Flash Builder 4\Senocular\src\com\senocular\utils\KeyObject.as:23]
at SeikatsuSamurai/init()[C:\Users\Alistair\Adobe Flash Builder 4\SeikatsuSamurai\src\SeikatsuSamurai.as:31]
Senocular’s KeyObject Class:
line 17 dynamic public class KeyObject extends Proxy {
private static var stage:Stage;
private static var keysDown:Object;
public function KeyObject(stage:Stage) {
construct(stage);
}
public function construct(stage:Stage):void {
KeyObject.stage = stage;
keysDown = new Object();
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyPressed);
stage.addEventListener(KeyboardEvent.KEY_UP, keyReleased);
}
My Code Which Acesses the KeyObject Class:
public class SeikatsuSamurai extends Sprite{
private var SamuraiChar:Samurai;
private var key:KeyObject;
private var stageRef:Stage;
public function SeikatsuSamurai(){
addEventListener(Event.ADDED_TO_STAGE, init);
}
public function init(e:Event):void{
key = new KeyObject(stageRef);
SamuraiChar = new Samurai();
addChild(SamuraiChar);
addEventListener(Event.ENTER_FRAME, loop, false, 0, true);
}
public function loop(e:Event):void{