Error #1009: Cannot access a property or method of a null object reference

Hi all, I’m new to Flash and I’m having some issues with my code. It was working fine until I made some unrelated changes (highlighted in the code) and now suddenly my move the player function won’t run.


import flash.events.Event;

var KeyThatsPressed = uint;
var rightKeyIsDown:Boolean = false;
var leftKeyIsDown:Boolean = false;
var upKeyIsDown:Boolean = false;
var downKeyIsDown:Boolean = false;

var PlayerSpeed:Number = 7;
var gravity:Number = 1;
var yVelocity:Number = 0;
var canJump:Boolean=false;
player_mc.gotoAndStop(1);

stage.addEventListener(KeyboardEvent.KEY_DOWN, PressAKey);
stage.addEventListener(KeyboardEvent.KEY_UP, ReleaseAKey);



//Press A Key
function PressAKey(event:KeyboardEvent):void
{
	if(event.keyCode == Keyboard.RIGHT){
		rightKeyIsDown = true;
		player_mc.gotoAndStop(2);
	}
		if(event.keyCode == Keyboard.LEFT){
		leftKeyIsDown = true;
		player_mc.gotoAndStop(3);
	}
		if(event.keyCode == Keyboard.UP){
		upKeyIsDown = true;
		player_mc.gotoAndStop(4);
	}

}


//Release A Key
function ReleaseAKey(event:KeyboardEvent):void
{
	if(event.keyCode == Keyboard.RIGHT){
		rightKeyIsDown = false;
		player_mc.gotoAndStop(1);
	}
		if(event.keyCode == Keyboard.LEFT){
		leftKeyIsDown = false;
		player_mc.gotoAndStop(1);
	}
		if(event.keyCode == Keyboard.UP){
		upKeyIsDown = false;
		player_mc.gotoAndStop(1);
	}
}

player_mc.addEventListener (Event.ENTER_FRAME, moveThePlayer);

[COLOR="Blue"]function moveThePlayer(event:Event):void[/COLOR]
{
	if(rightKeyIsDown)
	{
		player_mc.x +=5;
	}
	if(leftKeyIsDown)
	{
		player_mc.x -=5;
	}
		if(upKeyIsDown&&canJump)
		{
			yVelocity = -15;
			canJump=false;
		}
	yVelocity+=gravity;

	if(!floor_mc.hitTestPoint(player_mc.x, player_mc.y, true))
	{
	player_mc.y+=yVelocity
	}
	if(yVelocity>20)
	{
		yVelocity = 20;
	}
	for(var i:int = 0;i<10;i++)
	{
		if(floor_mc.hitTestPoint(player_mc.x,player_mc.y, true))
		{
			player_mc.y--;
			yVelocity = 0;
			canJump = true;
		}
	}
	if (coin_mc.hitTestObject(player_mc)){
	coin_mc.x = -100
	}

	if (coin2_mc.hitTestObject(player_mc)){
	coin2_mc.x = -100
	}
	if (coin2_mc.x == -100){
		door_mc.gotoAndStop(2);
	}
[COLOR="DarkOrange"]	if (player_mc.hitTestObject(door_mc)){
		gotoAndStop(2);
		}
	if (enemy_mc.hitTestObject(player_mc)){
		player_mc.x = -100;
		gotoAndStop(3);
	}[/COLOR]
}


The Orange text is what I’ve added that seems to have kicked off my issue. The Blue line is where I think my issue is. Here’s the full error message.

“TypeError: Error #1009: Cannot access a property or method of a null object reference.
at BasicGame_fla::MainTimeline/moveThePlayer()”

Thanks in advance.