4 Replies Latest reply on May 3, 2013 6:52 PM by Ned Murphy

    How to execute a function every certain period of time?

    Daniel12378992

      Hi guys!I have a very simple question.I have a budget and income variables.I want to make the player to recieve income every minute.But it's quite uncofortable to create a loop for every particular minute like if (minutes==1){} if (minutes==2){} and so on.How can make this loop occur every 60 seconds?

      Thanks

       

      var fl_SecondsElapsed_3:Number = 1;

      var minutes=2/fl_SecondsElapsed_3;

       

       

      function fl_TimerHandler_3(event:TimerEvent):void

      {

                trace("Прошло секунд: " + fl_SecondsElapsed_3);

                fl_SecondsElapsed_3++;

                if (fl_SecondsElapsed_3==60){

      budget=budget+income;

      }

      }