Skip to main content
Participant
May 18, 2023 1:22 AM UTC
Question

setInterval function to refresh new Date?

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 is closed to new replies. Start a new post to keep the conversation going.

    3 replies

    kglad
    Community Expert
    Community Expert
    May 18, 2023 1:30 AM UTC

    any loop will work.

     

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

     

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

    }

    Translate
    Participant
    May 18, 2023 11:45 PM UTC

    Works beautifully, thank you!

    Translate
    kglad
    Community Expert
    Community Expert
    May 18, 2023 11:50 PM UTC

    you're welcome.

    Translate