Search code examples
flashactionscript

how to I keep the result of the level in actionscript?


I want to do a game which can save the users who have attempt on the level. For example , the user played 2 quiz in level 5 , 1 quiz in level 6 and etc... I want to printed the result out.

Here is my last frame that print the result. My timer still could not shown the timing but it printed "time elapsed [object timer]" .

score.text = myscore+""; // updating the score 

if(myscore>=40){smiley.visible=true}
else
{smiley.visible=false}

// stopping the timer on the  last frame

myTimer.stop();
countdown1.text = "Time elapsed" +myTimer+"";
myTimer.stop();

Solution

  • If you just want to show the amount of time that has passed since you started your timer, you can use the Timer.currentCount and Timer.delay properties.

    Timer.currentCount is the number of times the counter has fired and delay is the amount of time between the TimerEvent.TIMER events.

    Try going:

    // divide by 1000 as the time is in ms
    countdown1.text = "Time elapsed: " + (myTimer.currentCount * myTimer.delay / 1000).toString();
    

    You can also shorten your if statement by going:

    smiley.visible = (myscore >= 40)