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

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

Community Beginner ,
Dec 01, 2015 Dec 01, 2015

Copy link to clipboard

Copied

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();

  }

  }

  }

}

TOPICS
ActionScript

Views

413

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

Community Expert , Dec 01, 2015 Dec 01, 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.

Votes

Translate

Translate
Community Expert ,
Dec 01, 2015 Dec 01, 2015

Copy link to clipboard

Copied

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.

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
Community Beginner ,
Dec 01, 2015 Dec 01, 2015

Copy link to clipboard

Copied

LATEST

Required a silly fix. Flash is so iffy sometimes.

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