I’m busy programming a game, but I’ve run stuck on something.
I’ve been able to let the game work perfectly before, but all of the sudden it stopped working.
Here is the part of the script that is giving the error:
var colorTransform:ColorTransform;
var player:MovieClip;
var kaas:MovieClip;
var ground:MovieClip;
var speed:Number;
var right:Boolean = false;
var left:Boolean = false;
var up:Boolean = false;
var down:Boolean = false;
var isWalking:Boolean = false;
var isJumping:Boolean = false;
var jumpSpeedLimit:int = 14;
var jumpSpeed:Number = jumpSpeedLimit;
// END
public function main()
{
speed = 5;
kaas = new Kaas();
kaas.y = 300;
kaas.x = 300;
addChild(kaas);
ground = new Ground();
ground.y = stage.stageHeight;
ground.x = stage.stageWidth / 2;
addChild(ground);
player = new Player();
player.x = stage.stageWidth / 2 - player.width;
player.y = stage.stageHeight - 45;
player.width = 50;
player.height = 50;
addChild(player);
player.gotoAndStop("idle");
//event listeners.
stage.addEventListener(KeyboardEvent.KEY_UP, keyupCheck);
stage.addEventListener(KeyboardEvent.KEY_DOWN, keydownCheck);
player.addEventListener(Event.ENTER_FRAME, movePlayer);
}
I hope someone could help me out.
this is the error message I get:
typeerror error #1009 cannot access a property or method of a null object reference.at main()
Thanks in advance,
Remy
The error means you are trying to access a property, but that object has not been instantiented/does not exist/is currently null.
I’m not 100% sure which of the classes you use in main() might not be ready, but a very common one is the stage, which is a null object the display object has been added to the stage.
In this case try something like this in the last part of main():