Skip to main content
Inspiring
April 11, 2013
Answered

Logic behind the error??

  • April 11, 2013
  • 1 reply
  • 1178 views

It's a countdown clock.

At the start it loads a time to begin the countdown. The countdwon continues until condition1 is false. While condition1 is false, if button15 is clicked the countdown should continue from where it left.

My question is when button15 is clicked, the countdown does not continue from where it left? It continues as _root.onEnterFrame = CountDown; has kept on going while conditionA was false?? How do I make the countdown clock continue from where condition1 was false?

?

var start_dateFixed:Date = new Date();

var start_milFixed:Number = start_dateFixed.getTime();

var start_secondsFixed:Number = start_milFixed/1000;

SndLoad.sendAndLoad("http://www.web.com/the.php",RscLoad,"POST");

RecLoad.onData = function(src) {

     var a:Array=src.split(",,");

     var Bcountdown = Math.floor(60 - a[0]);

     timeRem.text = Math.floor((Bcountdown) + (start_secondsFixed));

     _root.onEnterFrame = CountDown;

}

function CountDown(){

if (conditionA == true) {

   var bringTimeSrt = timeRem.text;

  var start_date:Date = new Date();

  var start_mil:Number = start_date.getTime();

  var start_seconds:Number = start_mil/1000;

  var remTIme = bringTimeSrt - start_seconds;

 

  var sec = Math.floor(remTIme);

  var min = Math.floor(sec/60);

  var hrs = Math.floor(min/60);

  sec = string(sec % 60);

  if(sec.length < 2) {

  sec = "0" + sec;

  }

  min = string(min % 60);

  if(min.length < 2) {

  min = "0" + min;

  }

  hrs = string(hrs % 24);

  if(hrs.length < 2) {

  hrs = "0" + hrs;

  }

  var theRemPeriod:String = hrs + " : " + min + " : " + sec;

  cntDwnClock.text = theRemPeriod;

}

}

function newFunction() {

if (condition1==true) {

conditionA

}

}

triggerConditionA = setInterval(newFunction, 2000);

button15.onRelease = function () { // does not contine from where it stopped?

  var start_dateFixed:Date = new Date();

  var start_milFixed:Number = start_dateFixed.getTime();

  var start_secondsFixed:Number = start_milFixed/1000;

  timeRem.text="";

  SndLoad.sendAndLoad("http://www.web.com/the.php",RscLoad,"POST");

}

This topic has been closed for replies.
Correct answer Ned Murphy

WHat of the code you show is supposed to be stopping the countdown?

YOur problem might have to do with using the Date class to acquire values, though I cannot be sure.  If you are relying on it then it might be updating to the current time rather than picking up from some previous value.

1 reply

Ned Murphy
Ned MurphyCorrect answer
Legend
April 11, 2013

WHat of the code you show is supposed to be stopping the countdown?

YOur problem might have to do with using the Date class to acquire values, though I cannot be sure.  If you are relying on it then it might be updating to the current time rather than picking up from some previous value.

Inspiring
April 11, 2013

this should stop the countdown.

function newFunction() {

if (condition1==true) {

conditionA

}

}

triggerConditionA = setInterval(newFunction, 2000);

Ned Murphy
Legend
April 11, 2013

I don't see where you define conditionA nor do I see where you change its value.  The following does nothing that I can see...

if (condition1==true) {

conditionA    ???? what is this doing?

}