3 Replies Latest reply on Dec 17, 2017 6:55 AM by kglad

    30 Second Countdown Timer


      Hi, I am trying to create a countdown that counts down from 30 seconds for my game.

      This is my code:

      var secondsLeft = 30;
      this.countdown_txt.text = secondsLeft;
      var timerId = setInterval(countdown, 1000);
      function countdown(){
      if(secondsLeft == 0){
           this.countdown_txt.text = secondsLeft;

      When I run this I get an error that occurs on line 11: Uncaught TypeError: Cannot set property 'text' of undefined.

      I'm not sure why this is the case as I have a similar setup for counting the score when clicking on a movieclip and that works fine. Any help would be appreciated.