• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

Community Beginner ,
Nov 30, 2015 Nov 30, 2015

Copy link to clipboard

Copied

package 

{

  import flash.display.MovieClip;

  import flash.events.Event;

  import flash.utils.Timer;

  import flash.text.TextField;

  import flash.text.TextFormat;

  public class Game extends MovieClip

  {

  static var boat:MovieClip;

  static var enemyShipTimer:Timer;

  static var scoreText:TextField;

  static var score:Number

  static var healthMeter:HealthMeter;

  static var gameOverMenu:GameOverMenu;

  static var powerUpTimer:Timer;

  static var miniBossTimer:Timer;

  static var bossCountDown:Number;

  public function Game()

  {

  Key.initialize(stage);

  boat = new Boat();

  addChild(boat);

  boat.shield.visible = false;

  bossCountDown = 3;

  boat.x = 300

  boat.y = 150

  enemyShipTimer = new Timer(1000);

  enemyShipTimer.addEventListener("timer", sendEnemy);

  enemyShipTimer.start();

  miniBossTimer.start();

  var scoreFormat = new TextFormat("Calabri MS", 20, 0XFFFFFF);

  scoreText = new TextField();

  scoreText.defaultTextFormat = scoreFormat;

  scoreText.x = 290;

  scoreText.text = String(0);

  addChild(scoreText);

  healthMeter = new HealthMeter();

  addChild(healthMeter);

  healthMeter.x = 10;

  healthMeter.y = 10;

  

  gameOverMenu = new GameOverMenu();

  gameOverMenu.x = 300;

  gameOverMenu.y = 150;

  addChild(gameOverMenu);

  gameOverMenu.visible = false;

  gameOverMenu.playAgainButton.addEventListener("mouseDown", newGame);

  powerUpTimer = new Timer(10000);

  powerUpTimer.addEventListener("timer", sendPowerUp);

  powerUpTimer.start();

  miniBossTimer = new Timer (20000);

  miniBossTimer.addEventListener("timer", sendMiniBoss);

  miniBossTimer.start();

  resetScore();

  }

  function sendMiniBoss(e:Event)

  {

  miniBossTimer.stop();

  if(bossCountDown ==0)

  {

  var boss = new Boss();

  stage.addChild(boss);

  bossCountDown = 3;

  }

  else

  {

  var miniBoss = new MiniBoss();

  stage.addChild(miniBoss);

  bossCountDown -= 1;

  }

  }

  function sendEnemy(e:Event)

  {

  var enemy = new EnemyShip();

  stage.addChild(enemy);

  }

  function sendPowerUp(e:Event)

  {

  var powerUp = new PowerUp();

  stage.addChild(powerUp);

  }

  static function updateScore(points)

  {

  score += points;

  scoreText.text = String(score);

  }

  static function resetScore()

  {

  score = 0;

  scoreText.text = String(score);

  }

  function newGame(e:Event)

  {

  gameOverMenu.visible = false;

  boat.visible = true;

  boat.x = 300;

  boat.y = 150;

  boat.takeDamage(-boat.maxHealth);

  boat.addEventListener("enterFrame",boat.move);

  resetScore();

  enemyShipTimer.start();

  }

  static function gameOver()

  {

  gameOverMenu.visible = true;

  enemyShipTimer.stop();

  miniBossTimer.stop();

  for(var i in EnemyShip.list)

  {

  EnemyShip.list.kill();

  }

  }

  }

}

TOPICS
ActionScript

Views

298

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Enthusiast , Nov 30, 2015 Nov 30, 2015

You only need to remove the line 35: miniBossTimer.start();

because it cannot be started with null values..

Votes

Translate

Translate
Community Beginner ,
Nov 30, 2015 Nov 30, 2015

Copy link to clipboard

Copied

Says line 35 is the issue?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Nov 30, 2015 Nov 30, 2015

Copy link to clipboard

Copied

LATEST

You only need to remove the line 35: miniBossTimer.start();

because it cannot be started with null values..

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines