Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Logic behind the error??

Participant ,
Apr 11, 2013 Apr 11, 2013

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");

}

TOPICS
ActionScript
984
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Apr 11, 2013 Apr 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.

Translate
LEGEND ,
Apr 11, 2013 Apr 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 11, 2013 Apr 11, 2013

this should stop the countdown.

function newFunction() {

if (condition1==true) {

conditionA

}

}

triggerConditionA = setInterval(newFunction, 2000);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 11, 2013 Apr 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?

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 11, 2013 Apr 11, 2013

it goes like this:

var cCount:Number = 0;

function newFunction() {

if (condition==true) {

     if (cCount < 2) {

cCount++;

         } else {

   timeRem.text="";

         }

         } else {

cCount = 0;

         }

}

triggerConditionA = setInterval(newFunction, 2000);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 11, 2013 Apr 11, 2013

You lost me with that response.  How does that relate to conditionA?  How does that explain the line I added all the question marks to?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 11, 2013 Apr 11, 2013

conditionA is checking whether cCount < 2

The countdwon continues until cCount = 2. then the countdown stops and while cCount = 2, if button15 is clicked the countdown to be continued from where it left.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 12, 2013 Apr 12, 2013
LATEST

Thanks for your time Ned. Got it sorted. Issue was having the Date class acquiring values in the incorrect place in the code....

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Apr 11, 2013 Apr 11, 2013

Thanks Ned.

if the the issue is with the Date class to acquiring values, how should this be approached?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines