Hey yall!
Ok here´s my gamepage, what I want to do is let a lister triggered function create a new timer, but somehow it doesn´t work. Hope anyone hava a clue, I´m so tired of these problems.
class classesUI.GamePage extends MovieClip
{
private var timeKeeper:TimerExtended;//Special class
private var roundTimes:Number;
private var roundTimeKeeper:Number;
private var gameTimeKeeper:Number;
public function GamePage()
{
}
//Init
function onLoad()
{
roundTimes = 0;
roundTimeKeeper = timeKeeper.intervalCall(1000, -1, Delegate.create(this, roundTimer));
//This works, but I don´t want to do this here, I want to do this on onGameStartEvent();
addTimer();
}
private function roundTimer():Void
{
//This works
roundTimes = roundTimes + 1;
_root.mainShell.roundTimer_txt.text = "Round timer:" + roundTimes;
}
public function addTimer():Void
{
gameTimeKeeper = timeKeeper.intervalCall(1000, 60, Delegate.create(this, timerTick));
}
public function timerTick():Void
{
//this never gets triggered unless from onLoad(), why is that??
_root.oppTimer--;
}
//This function is beeing called from another class with this class registered as a listener
public function onGameStartEvent(newGameStartEvent:GameStartEvent)
{
addTimer();
}
}