Skip to main content
Participant
December 1, 2015
Answered

ReferenceError: Error #1056: Cannot create property gameOverMenu on Game. - pls help :(

  • December 1, 2015
  • 1 reply
  • 567 views

ReferenceError: Error #1056: Cannot create property gameOverMenu on Game.

  at flash.display::Sprite/constructChildren()

  at flash.display::Sprite()

  at flash.display::MovieClip()

  at Game()***************************:16]

Cannot display source code at this location.

~~~~~~~~~~~~~~~~

Game.as code:

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 character:MovieClip;

  static var enemyTimer:Timer;

  static var scoreText:TextField;

  static var score:Number;

  static var healthMeter:HealthMeter;

  static var gameOverMenu:GameOverMenu;

  public function Game() {

  Key.initialize(stage);

  character = new Character();

  addChild(character);

  enemyTimer = new Timer(1000);

  enemyTimer.addEventListener("timer", sendEnemy);

  enemyTimer.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);

  resetScore();

  }

  function sendEnemy(e: Event) {

  var enemy = new Enemy();

  stage.addChild(enemy);

  }

  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;

  character.visible = true;

  character.x = 300;

  character.y = 150;

  character.takeDamage(-character.maxHealth);

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

  resetScore();

  enemyTimer.start();

  }

  static function gameOver() {

  gameOverMenu.visible = true;

  enemyTimer.stop();

  for (var i in Enemy.list) {

  Enemy.list.kill();

  }

  }

  }

}

This topic has been closed for replies.
Correct answer kglad

i don't see a problem with your code but, of course, i can't tell if you really have a class named GameOverMenu in your class path.  and i can't see any reason for any static variables/functions.

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
December 1, 2015

i don't see a problem with your code but, of course, i can't tell if you really have a class named GameOverMenu in your class path.  and i can't see any reason for any static variables/functions.

Participant
December 1, 2015

Required a silly fix. Flash is so iffy sometimes.