Hi I’m new to flash and this is my first project. I got stuck many times but I managed to solve everything but the last part of the one-click-game I’m making.
The main concept is to click when scene 3 is played and that will stop the timer. if the timer is less then the reaction time set you can proceed to lvl 2, if not game over.
there are 10 lvls, this is how I’ve imagined that to work, every lvl only rtime should change, but it doesn’t.
scene Ovca is the scene played before the you have to click.
//1
btnplaylvl.addEventListener(MouseEvent.CLICK, btn11);
function btn11(event:MouseEvent):void{
rtime = undefined;
myTimer = undefined;
var rtime:Number = 1000;
gotoAndPlay(1,"Ovca");
}
this code should work on the scene where you have to click. but there is a problem, flash isnt counting milliseconds properly? is that possible? if i set it to 1000 ms it counts time perfectly fine.
var myTimer:Timer = new Timer(1);
myTimer.addEventListener(TimerEvent.TIMER, tick);
btnstop.addEventListener(MouseEvent.CLICK, zaustavi);
var timerValue = 0;
function tick (e:TimerEvent):void{
timerValue++;
txtrez.text = timerValue;
}
function zaustavi(e:MouseEvent):void{
myTimer.stop();
}
myTimer.start();
the scene where it is decided on which lvl it should jump, i dont know how to use a for loop there.
if (rtime==1000){
gotoAndStop(1,"Level Completed");
}
if (rtime==833){
gotoAndStop(2,"Level Completed");
}
if (rtime==556){
gotoAndStop(3,"Level Completed");
}
if (rtime==417){
gotoAndStop(4,"Level Completed");
}
if (rtime==333){
gotoAndStop(5,"Level Completed");
}
if (rtime==275){
gotoAndStop(6,"Level Completed");
}
if (rtime==238){
gotoAndStop(7,"Level Completed");
}
if (rtime==207){
gotoAndStop(8,"Level Completed");
}
if (rtime==189){
gotoAndStop(9,"Level Completed");
}
if (rtime==177){
gotoAndStop(1,"Game Over");
}
and the last delicious part, somehow this code isnt working
var miTimer = Number(myTimer);
if (rtime>=miTimer){
gotoAndPlay(1,"DA");
} else {
gotoAndPlay(1,"NE");
}
To any1 reading this long post, thank you for your time. I appreciate any help given. I am out of ideas how to solve this.