CountdownDisplayMain.as, Line 16 1119: Access of possibly undefined property CountdownClockDisplay through a reference with static type Class. and also the same on line 27
package { import flash.display.MovieClip; import flash.events.TimerEvent; import flash.utils.Timer; public class CountdownDisplayMain extends MovieClip { var time:Number; var timeTimer:Timer;
public function CountdownDisplayMain() { time + 60; CountdownDisplayMain.CountdownClockDisplay.text = time.toString(); timeTimer = new Timer(1000); timeTimer.addEventListener(TimerEvent.TIMER,countdown); timeTimer.start(); } function countdown(Event:TimerEvent) { time -= 1; CountdownDisplayMain.CountdownClockDisplay.text = time.toString(); }
} }
In my document class i have the following
var countdownDisplayMain:CountdownDisplayMain = new CountdownDisplayMain(); countdownDisplayMain.x = 50; countdownDisplayMain.y = 350; addChild(countdownDisplayMain);
in the properties panel where you put the instance name look down to behavior and select single line and also take note of the width of your txt box, can it support 2 digits?
C:\\Users\\Alex The Best\\Documents\\My Games\\Platformer\\Classes\\CountdownDisplayMain.as, Line 32 1137: Incorrect number of arguments. Expected no more than 0.
line 32 is the dispatch event line
Document class
package { import flash.display.MovieClip; public class Document extends MovieClip{ public var game:GameClass;
public function Document() { game = new GameClass(stage); game.addEventListener(GameEvent.FINISH, onGameFinish); addChild(game); } public function onGameFinish(gameEvent:GameEvent) { var darkBackScreenarkBackScreen = new DarkGameScreen(); darkBackScreen.x = 0; darkBackScreen.y = 0; addChild(darkBackScreen); game = null; }
} }
function countdown(Event:TimerEvent) { time -= 1; CountdownClockDisplay.text = time.toString(); if(time == 0) { timeTimer.stop(); dispatchEvent(new GameEvent(GameEvent.FINISH)); } }
it kind of looks like you're reference a dispatching class, although I personally don't like using a class for dispatched event's it would probably look something like this
package { import flash.events.*; public class GameEvent extends Event { public static const STARTGAME:String = "start"; public static const RESTARTGAME:String = "restart"; public static const FINISH:String = "finish"; public function GameEvent(type:String) { super(type); } } }
---------------------------------------------------------------- this is how I like to do it
in your document class the listener would look like this
game.addEventListener("dispatch", onGameFinish);
then the dispatcher in your game class will look like this
dispatchEvent(new Event("dispatch", true));
the text that is quoted can be changed to whatever ex. "GAMEOVER" but the listener and the dispatch must match