Cannot access a property or method of a null object reference

Hi guy:)

I need urgent help. I am making a platform game for college. I have to handle it next week. The code works fine until the player has lost all his health and is game over.

The problem is in the coin class: Coin.as

The code looks like this:

package {
	import flash.display.MovieClip;
	import flash.events.*;
	public class Coin extends MovieClip {
		var health = 6;
		var player_mc: MovieClip;
		private var MainTimeLine = MovieClip(root);
		public function Coin() {
			addEventListener(Event.ADDED_TO_STAGE, init);
		}
		private function init(event: Event): void {
			removeEventListener(Event.ADDED_TO_STAGE, init);
			this.addEventListener(Event.ENTER_FRAME, update);
		}
		function update(event: Event): void {
			trace(root);
			trace("variable:" + player_mc);
			player_mc = MovieClip(root).player_mc;
			if (this.hitTestObject(player_mc)) {
				this.removeEventListener(Event.ENTER_FRAME, update);
				parent.removeChild(this);
				MainTimeLine.coinCount++;
			}
		}
	}
}

The error message comes at line: 26, which is:

player_mc = MovieClip(root).player_mc;

Please help. I am trying now since a week to solve that problem, but without success:diss: