Copy link to clipboard
Copied
Dear all,
I have seen how brilliant and helpful you have been to users with some flash coding issues, and I hoped you may be able to help me.
I am creating an animation to display on a treadmill, including three counters which, rather than loop over a temporal cycle should continue infinitely. The 3 timers are:
(1) run timer starting from 46:00 minutes, resetting at 59:59.
(2) calories burning
(3) miles increase
2&3 being very similar and requiring only a variable of time delay between incremental figures. I hope you might be able to help me? Thanks for your time.
1 Correct answer
The following codes are husky I'm sure, but they're currently working for HTML. All are based on the same fundamental code.
Code for Incremental Time starting whenever User chooses (Time):
var that = this;
this.initialMinutes = 46.4; // display here
this.totalTime = 0;
this.currentTime = 0;
this.interval = 0;
this.start = function()
{
that.startTimer(that.updateCallBack, that.endCallback);
};
this.updateCallBack = function()
{
that.setText();
};
this.startTimer = fun
...Copy link to clipboard
Copied
Today I learned there are treadmills where the screen is actually displaying a web browser.
Since you tagged this as HTML, i assume you're working in an HTML5 Canvas document. That means JavaScript. So just use the JavaScript function for this:
Copy link to clipboard
Copied
Thank you. Perhaps I may disturb you by admitting that I'm not entirely sure how to apply this. There is very little scope to my knowledge, and I would be humbled if anyone could provide a line-by-line code for the three dynamic texts. Forgive me!
Copy link to clipboard
Copied
PS. I am flexible. Try me at HTML or ActionScript, I will rise to the challenge. It will be exported as OAM for Adobe Muse imbedding.
Copy link to clipboard
Copied
It's impossible for anyone to tell you what exactly to do, because only you know exactly how your application is internally organized.
Copy link to clipboard
Copied
Managed to cook up this for the Timer for HTML5 (below). Any chance to reset at 60:00?
var that = this;
this.initialMinutes = 46.4;// minutes here
this.totalTime = 0;
this.currentTime = 0;
this.interval = 0;
this.start = function()
{
that.startTimer(that.updateCallBack, that.endCallback);
};
this.updateCallBack = function()
{
that.setText();
};
this.startTimer = function(updateCallback, endCallback)
{
clearInterval(that.interval);
that.totalTime = that.minutesToMilliseconds(that.initialMinutes);
that.currentTime = that.totalTime;
that.setText();
that.setTime(updateCallback, endCallback);
};
this.setTime = function(updateCallback, endCallback)
{
that.interval = setInterval(function()
{
that.currentTime += 1000;
updateCallback();
if (that.currentTime == 60)
{
clearInterval(that.interval);
endCallback();
}
}, 100);//speed here
};
this.setText = function()
{
var time = that.timeCode(that.currentTime);
that.timeText.text = time.minutes + ":" + time.seconds;
};
this.minutesToMilliseconds = function(minutes)
{
return 1000 * 60 * minutes;
};
this.timeCode = function(milliseconds)
{
var seconds = Math.floor((milliseconds / 1000) % 60);
var strSeconds = (seconds < 10) ? ("0" + String(seconds)) : String(seconds);
var minutes = Math.round(Math.floor((milliseconds / 1000) / 60));
var strMinutes = (minutes < 10) ? ("0" + String(minutes)) : String(minutes);
return {seconds: strSeconds, minutes: strMinutes};
};
this.start();
Copy link to clipboard
Copied
The following codes are husky I'm sure, but they're currently working for HTML. All are based on the same fundamental code.
Code for Incremental Time starting whenever User chooses (Time):
var that = this;
this.initialMinutes = 46.4; // display here
this.totalTime = 0;
this.currentTime = 0;
this.interval = 0;
this.start = function()
{
that.startTimer(that.updateCallBack, that.endCallback);
};
this.updateCallBack = function()
{
that.setText();
};
this.startTimer = function(updateCallback, endCallback)
{
clearInterval(that.interval);
that.totalTime = that.minutesToMilliseconds(that.initialMinutes);
that.currentTime = that.totalTime;
that.setText();
that.setTime(updateCallback, endCallback);
};
this.setTime = function(updateCallback, endCallback)
{
that.interval = setInterval(function()
{
that.currentTime += 1000;
updateCallback();
if (that.currentTime == 60)
{
clearInterval(that.interval);
endCallback();
}
}, 1000); // rate of refresh here
};
this.setText = function()
{
var time = that.timeCode(that.currentTime);
that.timeText.text = time.minutes + ":" + time.seconds;
};
this.minutesToMilliseconds = function(minutes)
{
return 1000 * 60 * minutes;
};
this.timeCode = function(milliseconds)
{
var seconds = Math.floor((milliseconds / 1000) % 60);
var strSeconds = (seconds < 10) ? ("0" + String(seconds)) : String(seconds);
var minutes = Math.round(Math.floor((milliseconds / 1000) / 60));
var strMinutes = (minutes < 10) ? ("0" + String(minutes)) : String(minutes);
return {seconds: strSeconds, minutes: strMinutes};
};
this.start();
Code for Random Number (Heartrate):
var that = this;
this.initialMinutes = 10410; // display here
this.totalTime = 0;
this.currentTime = 0;
this.interval = 0;
this.start = function()
{
that.startTimer(that.updateCallBack, that.endCallback);
};
this.updateCallBack = function()
{
that.setText();
};
this.startTimer = function(updateCallback, endCallback)
{
clearInterval(that.interval);
that.totalTime = that.minutesToMilliseconds(that.initialMinutes);
that.currentTime = that.totalTime;
that.setText();
that.setTime(updateCallback, endCallback);
};
this.setTime = function(updateCallback, endCallback)
{
that.interval = setInterval(function()
{
that.currentTime += 1000;
updateCallback();
}, 5535); // rate of refresh here
};
this.setText = function()
{
var time = that.timeCode(that.currentTime);
that.timeText.text = time.minutes;
};
this.minutesToMilliseconds = function(minutes)
{
return 100 * 60 * minutes;
};
this.timeCode = function(milliseconds)
{
var seconds = Math.ceil(Math.random() * 5 + 130);
var minutes = Math.ceil(Math.random() * 5 + 130);
return {seconds, minutes};
};
this.start();
Code for Incremental Numbers (Calories):
var that = this;
this.initialMinutes = 10410; // display here
this.totalTime = 0;
this.currentTime = 0;
this.interval = 0;
this.start = function()
{
that.startTimer(that.updateCallBack, that.endCallback);
};
this.updateCallBack = function()
{
that.setText();
};
this.startTimer = function(updateCallback, endCallback)
{
clearInterval(that.interval);
that.totalTime = that.minutesToMilliseconds(that.initialMinutes);
that.currentTime = that.totalTime;
that.setText();
that.setTime(updateCallback, endCallback);
};
this.setTime = function(updateCallback, endCallback)
{
that.interval = setInterval(function()
{
that.currentTime += 1000;
updateCallback();
if (that.currentTime == 60)
{
clearInterval(that.interval);
endCallback();
}
}, 100); // rate of refresh here
};
this.setText = function()
{
var time = that.timeCode(that.currentTime);
that.timeText.text = time.minutes;
};
this.minutesToMilliseconds = function(minutes)
{
return 100 * 60 * minutes;
};
this.timeCode = function(milliseconds)
{
var seconds = Math.floor((milliseconds / 1000) % 60);
var strSeconds = (seconds < 10) ? ("0" + String(seconds)) : String(seconds);
var minutes = Math.round(Math.floor((milliseconds / 1000) / 60));
var strMinutes = (minutes < 10) ? ("0" + String(minutes)) : String(minutes);
return {seconds: strSeconds, minutes: strMinutes};
};
this.start();
Code for Incremental Numbers with Decimal (Miles):
var that = this;
this.initialMinutes = 61.3; // display here
this.totalTime = 0;
this.currentTime = 0;
this.interval = 0;
this.start = function()
{
that.startTimer(that.updateCallBack, that.endCallback);
};
this.updateCallBack = function()
{
that.setText();
};
this.startTimer = function(updateCallback, endCallback)
{
clearInterval(that.interval);
that.totalTime = that.minutesToMilliseconds(that.initialMinutes);
that.currentTime = that.totalTime;
that.setText();
that.setTime(updateCallback, endCallback);
};
this.setTime = function(updateCallback, endCallback)
{
that.interval = setInterval(function()
{
that.currentTime += 1000;
updateCallback();
if (that.currentTime == 10)
{
clearInterval(that.interval);
endCallback();
}
}, 4535); // rate of refresh here
};
this.setText = function()
{
var time = that.timeCode(that.currentTime);
that.timeText.text = time.minutes + "." + time.seconds;
};
this.minutesToMilliseconds = function(minutes)
{
return 1000 * 10 * minutes;
};
this.timeCode = function(milliseconds)
{
var seconds = Math.floor((milliseconds / 1000) % 100);
var strSeconds = (seconds < 10) ? ("0" + String(seconds)) : String(seconds);
var minutes = Math.round(Math.floor((milliseconds / 1000) / 100));
var strMinutes = (minutes < 1) ? ("0" + String(minutes)) : String(minutes);
return {seconds: strSeconds, minutes: strMinutes};
};
this.start();

