cannot access a property of a null object reference
Copy link to clipboard
Copied
Hi guys:)
I am trying to make a platform game with obstacles and coins. The coins are defined in a class. The code works fine until the player has lost all his health and is gameover. Then I get the error message that I have written above.
Here the code:
stop();
import flash.events.KeyboardEvent;
import flash.events.Event;
import flash.display.MovieClip;
import flash.utils.Timer;
import flash.display.Sprite;
//vars (define events and functions)
var bulletHolder:Sprite=new Sprite();
addChild(bulletHolder);
var KeyThatIsPressed:uint;
var rightKeyIsDown:Boolean=false;
var leftKeyIsDown:Boolean=false;
var upKeyIsDown:Boolean=false;
var downKeyIsDown:Boolean=false;
var spaceKeyIsDown:Boolean=false;
var cantShoot:Boolean=false;
var canShoot:Boolean=false;
var pistolCounter:int=0;
var pistolCountFrame:int=12;
var coinCount:int;
var hitObstacle:Boolean=false; // keeps track if obstacle is hit
var health=6;
health_txt.text=health.toString();
//propreties for player
stage.addEventListener(KeyboardEvent.KEY_DOWN, PressAKey);
stage.addEventListener(KeyboardEvent.KEY_UP, ReleaseAKey);
stage.addEventListener(Event.ENTER_FRAME, moveThePlayer);
function PressAKey(event:KeyboardEvent):void
{
if(event.keyCode==Keyboard.RIGHT)
{
rightKeyIsDown=true;
}
if(event.keyCode==Keyboard.LEFT)
{
rightKeyIsDown=true;
}
if(event.keyCode==Keyboard.UP)
{
upKeyIsDown=true;
}
if(event.keyCode==Keyboard.DOWN)
{
downKeyIsDown=true;
}
if(event.keyCode==Keyboard.SPACE)
{
spaceKeyIsDown=true;
}
}
function ReleaseAKey(event:KeyboardEvent):void
{
if(event.keyCode==Keyboard.RIGHT)
{
rightKeyIsDown=false;
}
if(event.keyCode==Keyboard.LEFT)
{
rightKeyIsDown=false;
}
if(event.keyCode==Keyboard.UP)
{
upKeyIsDown=false;
}
if(event.keyCode==Keyboard.DOWN)
{
downKeyIsDown=false;
}
if(event.keyCode==Keyboard.SPACE)
{
spaceKeyIsDown=false;
cantShoot=false;
}
}
function moveThePlayer(event:Event):void {
if(rightKeyIsDown)
{
player_mc.gotoAndStop(2);
}
if(leftKeyIsDown)
{
player_mc.gotoAndStop(2);
}
if(downKeyIsDown)
{
player_mc.gotoAndStop(2)
}
if(upKeyIsDown)
{
player_mc.gotoAndStop (3);
}
if(spaceKeyIsDown)
{
player_mc.gotoAndStop(3);
}
if(pistolCounter<pistolCountFrame)
{
pistolCounter++
}
if(pistolCounter>=pistolCountFrame)
{
canShoot=true;
pistolCounter=0;
}
if(spaceKeyIsDown&&!cantShoot&&canShoot)
{
var bullet_mc:MovieClip=new Bullet();
bullet_mc.x=player_mc.x
bullet_mc.y=player_mc.y
bullet_mc.rotation=player_mc.rotation_mc.rotation
bulletHolder.addChild(bullet_mc);
cantShoot=true;
canShoot=false;
}
}
if(rightKeyIsDown)
{
player_mc.rotation_mc.rotation=0
}
if(leftKeyIsDown)
{
player_mc.rotation_mc.rotation=180
}
//defines player
stage.addEventListener(KeyboardEvent.KEY_UP, run);
function run(e:KeyboardEvent):void{
player_mc.gotoAndStop(1);
}
stage.addEventListener(KeyboardEvent.KEY_UP, checkkeysup);
var speed=10;
var moveright=false;
function checkkeysdown(mykey:KeyboardEvent) {
if (mykey.keyCode==Keyboard.RIGHT) {
moveright=true;
}
}
function checkkeysup(mykey:KeyboardEvent) {
if (mykey.keyCode==Keyboard.RIGHT) {
moveright=false;
}
}
//defines obstacles
stage.addEventListener(Event.ENTER_FRAME, gameloop);
function gameloop(e:Event):void{
obstacle_mc.x-=20;
if (obstacle_mc.x<-100){
obstacle_mc.x=650;
hitObstacle=false;
}
if (player_mc.hitTestObject(obstacle_mc)) {
if (hitObstacle==false){ // only subtract health if hitObstacle is false
health--;
}
hitObstacle=true;
health_txt.text=health.toString();
if (health<=0){
stage.removeEventListener(KeyboardEvent.KEY_DOWN, PressAKey);
stage.removeEventListener(KeyboardEvent.KEY_UP, ReleaseAKey);
stage.removeEventListener(Event.ENTER_FRAME, moveThePlayer);
stage.removeEventListener(KeyboardEvent.KEY_UP, run);
stage.removeEventListener(KeyboardEvent.KEY_UP, checkkeysup);
stage.removeEventListener(Event.ENTER_FRAME, gameloop);
stage.removeEventListener(Event.ENTER_FRAME, axtloop);
gotoAndStop(1, "Scene 3");
}
}
}
stage.addEventListener(Event.ENTER_FRAME, axtloop);
function axtloop(e:Event):void{
axt_mc.x-=20;
if (axt_mc.x<-100){
axt_mc.x=650;
hitObstacle=false;
}
if (player_mc.hitTestObject(axt_mc)) {
if (hitObstacle==false){ // only subtract health if hitObstacle is false
health--;
}
hitObstacle=true;
health_txt.text=health.toString();
if (health<=0){
stage.removeEventListener(KeyboardEvent.KEY_DOWN, PressAKey);
stage.removeEventListener(KeyboardEvent.KEY_UP, ReleaseAKey);
stage.removeEventListener(Event.ENTER_FRAME, moveThePlayer);
stage.removeEventListener(KeyboardEvent.KEY_UP, run);
stage.removeEventListener(KeyboardEvent.KEY_UP, checkkeysup);
stage.removeEventListener(Event.ENTER_FRAME, gameloop);
stage.removeEventListener(Event.ENTER_FRAME, axtloop);
gotoAndStop(1, "Scene 3");
}
}
//counts coins
coinCount_txt.text="coins:"+coinCount;
}
The code for the coins:
package
{
import flash.display.MovieClip;
import flash.events.*;
import flash.net.dns.AAAARecord;
public class Coin extends MovieClip
{
var player_mc:MovieClip;
public var MainTimeLine=MovieClip(root);
public function Coin()
{
// constructor code
this.addEventListener(Event.ENTER_FRAME, update);
}
function update(event:Event):void
{
player_mc=MovieClip(root).player_mc
if(this.hitTestObject(player_mc))
{
this.removeEventListener(Event.ENTER_FRAME, update);
parent.removeChild(this);
MainTimeLine.coinCount++;
}
}
}
}
I really would appreciate some help because I am trying now since 5 days to solve the problem without success.
Many thanks in advance
Copy link to clipboard
Copied
Hi Ned
many thanks for the reply.
this is the full error message:
Fonts should be embedded for any text that may be edited at runtime, other than text with the "Use Device Fonts" setting. Use the Text > Font Embedding command to embed fonts.[SWF] Game%20copy%202.swf - 191091 bytes after decompressionTypeError: Error #1009: Cannot access a property or method of a null object reference. at Gamecopy2_fla::MainTimeline/axtloop()[Gamecopy2_fla.MainTimeline::frame1:213]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Bullet/update()[/Users/sonjacerny/Desktop/Platform Game/Bullet.as:30]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Bullet/update()[/Users/sonjacerny/Desktop/Platform Game/Bullet.as:30]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Bullet/update()[/Users/sonjacerny/Desktop/Platform Game/Bullet.as:30]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Bullet/update()[/Users/sonjacerny/Desktop/Platform Game/Bullet.as:30]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Bullet/update()[/Users/sonjacerny/Desktop/Platform Game/Bullet.as:30]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Bullet/update()[/Users/sonjacerny/Desktop/Platform Game/Bullet.as:30]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Bullet/update()[/Users/sonjacerny/Desktop/Platform Game/Bullet.as:30]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Bullet/update()[/Users/sonjacerny/Desktop/Platform Game/Bullet.as:30]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Bullet/update()[/Users/sonjacerny/Desktop/Platform Game/Bullet.as:30]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Bullet/update()[/Users/sonjacerny/Desktop/Platform Game/Bullet.as:30]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Bullet/update()[/Users/sonjacerny/Desktop/Platform Game/Bullet.as:30]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Bullet/update()[/Users/sonjacerny/Desktop/Platform Game/Bullet.as:30]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Bullet/update()[/Users/sonjacerny/Desktop/Platform Game/Bullet.as:30]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Bullet/update()[/Users/sonjacerny/Desktop/Platform Game/Bullet.as:30]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Bullet/update()[/Users/sonjacerny/Desktop/Platform Game/Bullet.as:30]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Bullet/update()[/Users/sonjacerny/Desktop/Platform Game/Bullet.as:30]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Bullet/update()[/Users/sonjacerny/Desktop/Platform Game/Bullet.as:30]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Bullet/update()[/Users/sonjacerny/Desktop/Platform Game/Bullet.as:30]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Bullet/update()[/Users/sonjacerny/Desktop/Platform Game/Bullet.as:30]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Bullet/update()[/Users/sonjacerny/Desktop/Platform Game/Bullet.as:30]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Bullet/update()[/Users/sonjacerny/Desktop/Platform Game/Bullet.as:30]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Bullet/update()[/Users/sonjacerny/Desktop/Platform Game/Bullet.as:30]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Bullet/update()[/Users/sonjacerny/Desktop/Platform Game/Bullet.as:30]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Bullet/update()[/Users/sonjacerny/Desktop/Platform Game/Bullet.as:30]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23]TypeError: Error #1009: Cannot access a property or method of a null object reference. at Coin/update()[/Users/sonjacerny/Desktop/Platform Game/Coin.as:23][UnloadSWF] Game%20copy%202.swfTest Movie terminated.Debug session terminated.
Could you help me solve the problem? Would mean a lot to me. Spend a lot of time and on that code and I am just not capable of solving the problem by myself:(
Date: Tue, 22 Apr 2014 10:37:26 -0700
From: forums_noreply@adobe.com
To: sonjacerny@hotmail.com
Subject: cannot access a property of a null object reference
Re: cannot access a property of a null object reference
created by Ned Murphy in ActionScript 3 - View the full discussion
The 1009 error indicates that one of the objects being targeted by your code is out of scope. This could mean that the object....
- is declared but not instantiated
- doesn't have an instance name (or the instance name is mispelled)
- does not exist in the frame where that code is trying to talk to it
- is animated into place but is not assigned instance names in every keyframe for it
- is one of two or more consecutive keyframes of the same objects with no name assigned in the preceding frame(s)
- is an object that was removed but code is still trying to target it
If you go into your Publish Settings Flash section and select the option to Permit debugging, your error message should have a line number following the frame number which will help you isolate which object is involved.
Please note that the Adobe Forums do not accept email attachments. If you want to embed a screen image in your message please visit the thread in the forum to embed the image at http://forums.adobe.com/message/6320249#6320249
Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page:
To unsubscribe from this thread, please visit the message page at . In the Actions box on the right, click the Stop Email Notifications link.
Start a new discussion in ActionScript 3 at Adobe Community
For more information about maintaining your forum email notifications please go to http://forums.adobe.com/thread/416458?tstart=0.
Copy link to clipboard
Copied
The errors appear to indicate you have issues with something not existing when you get to line 30 of your Bullet.as file and line 23 of your Coin.as file.
Due to the way the error repeats, I suspect there is some kind of looping going on where you continuously try to target an object that doesn't exist. When it comes to things like bullets, my immediate suspiscion is that you have bullets that are removed from play, but they are not removed from being looked for. If you happen to keep the bullets in an array, then your problem might lie in neglecting to remove them from that array after they are spent.


-
- 1
- 2