Make various countdowns in a single project FLASH

31 views Asked by At

I'm a begginer in Flash CC and I've a problem, I'm using a code to make a countdown that works perfect, this is the code:

var diaFinal:Date = new Date(2015,05,19, 3, 30);
var cronometroCuentaRegresiva:Timer = new Timer(1000);
cronometroCuentaRegresiva.addEventListener(TimerEvent.TIMER, actualizarHora);
cronometroCuentaRegresiva.start();
function actualizarHora(e:TimerEvent):void
{
    var hoy:Date = new Date();
    var tiempoRestante:Number = diaFinal.getTime() - hoy.getTime();
    var segundos:Number = Math.floor(tiempoRestante / 1000);
    var minutos:Number = Math.floor(segundos / 60);
    var horas:Number = Math.floor(minutos / 60);
    var dias:Number = Math.floor(horas / 24);
    
    segundos %= 60;
    minutos %= 60;
    horas %= 24;
    
    var sec:String = segundos.toString();
    var min:String = minutos.toString();
    var hrs:String = horas.toString();
    var d:String = dias.toString();
    
    if (sec.length < 2) {
        sec = "0" + sec;
    }
    
    if (min.length < 2) {
        min = "0" + min;
    }
    
    if (hrs.length < 2) {
        hrs = "0" + hrs;
    }
    
    var tiempo:String = d + ":" + hrs + ":" + min + ":" + sec;
    time_txt.text = tiempo;


if (time_txt.text < "00:00:00:00"){
time_txt.text = "¡GP de CANADÁ!";}
}

The problem that I've is when I try to create a new scene to do another countdown, I get the same date that I put in the first scene. Example

Scene 1: Date: (2015,05,19, 3,30) Scene 2: Date: (2015,05,19, 7,30)

Works perfectly but when I debug the project and change to scene 2 I get the same countdown as scene 1. I hope you can understand me, and can help me :)

0

There are 0 answers