Copy link to clipboard
Copied
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");
}
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
this should stop the countdown.
function newFunction() {
if (condition1==true) {
conditionA
}
}
triggerConditionA = setInterval(newFunction, 2000);
Copy link to clipboard
Copied
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?
}
Copy link to clipboard
Copied
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);
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Thanks for your time Ned. Got it sorted. Issue was having the Date class acquiring values in the incorrect place in the code....
Copy link to clipboard
Copied
Thanks Ned.
if the the issue is with the Date class to acquiring values, how should this be approached?
Find more inspiration, events, and resources on the new Adobe Community
Explore Now