Skip to main content
Participant
May 18, 2023
Question

setInterval function to refresh new Date?

  • May 18, 2023
  • 1 reply
  • 326 views

Hello, I apologize if this question has already been posted...  I'm trying to make a basic time/date in Animate.  If I use this.tf.text = new Date();  where tf is a dynamic text field, the .fla displays what I want.  My question is, is it possible to put this in a function and then use setInterval to essentially get a real time display?  If so, can someone help with the code?  I'm a mechanic by trade and hitting it with a hammer isn't working....

    This topic has been closed for replies.

    1 reply

    kglad
    Community Expert
    Community Expert
    May 18, 2023

    any loop will work.

     

    setInterval(updateF.bind(this),500);

     

    function updateF(){
    this.tf.text=new Date();  // you'll probably want to format this

    }

    Participant
    May 18, 2023

    Works beautifully, thank you!

    kglad
    Community Expert
    Community Expert
    May 18, 2023

    you're welcome.