Copy link to clipboard
Copied
Hi,
I found this js code and now I need to use it in an Adobe Animate. If it is possible? If so, I would like to put the counter in an animated dynamic text box.
<script>
// Set the date we're counting down to
var countDownDate = new Date("February 28, 24 21:35:00").getTime();
// Update the count down every 1 second
var x = setInterval(function() {
// Get today's date and time
var now = new Date().getTime();
// Find the distance between now and the count down date
var distance = countDownDate - now;
// Time calculations for days, hours, minutes and seconds
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
// Display the result in the element with id="demo"
document.getElementById("demo").innerHTML = hours + " godzin, "
+ minutes + " minut, " + seconds + " sekund ";
// If the count down is finished, write some text
if (distance < 0) {
clearInterval(x);
document.getElementById("demo").innerHTML = "End";
}
}, 1000);
</script>
Hi.
You just need to use a dynamic text field instance on stage instead of a DOM element to display the calculated time. Like this:
var root = this;
// Set the date we're counting down to
var countDownDate = new Date("February 28, 24 21:35:00").getTime();
// Update the count down every 1 second
var x = setInterval(function()
{
// Get today's date and time
var now = new Date().getTime();
// Find the distance between now and the count down date
var distance = countDownDate - now;
// T
...
Copy link to clipboard
Copied
Hi.
You just need to use a dynamic text field instance on stage instead of a DOM element to display the calculated time. Like this:
var root = this;
// Set the date we're counting down to
var countDownDate = new Date("February 28, 24 21:35:00").getTime();
// Update the count down every 1 second
var x = setInterval(function()
{
// Get today's date and time
var now = new Date().getTime();
// Find the distance between now and the count down date
var distance = countDownDate - now;
// Time calculations for days, hours, minutes and seconds
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
// Display the result in the element with id="demo"
root.yourTF.text = hours + " godzin, " // CHANGE HERE
+ minutes + " minut, " + seconds + " sekund ";
// If the count down is finished, write some text
if (distance < 0)
{
clearInterval(x);
root.yourTF.text = "End"; // CHANGE HERE
}
}, 1000);
Regards,
JC
Copy link to clipboard
Copied
You saved my ass... Thank you very much for your quick response!!!