title: AS3: Add Timer to running a function
body: <p>I'm trying to create a simple Timer for running a function. You can see in below :</p>
  
  <p>I would like to run <code>DiceOne</code> and <code>DieTwo</code> animations for a while.</p>
  
  <pre><code>rollBtn.addEventListener(MouseEvent.CLICK, rollBtnClicked);
  
  function rollBtnClicked(evt:MouseEvent):void {
      rollNum1 = rollDice();
      rollNum2 = rollDice();
  
      throwDice();
  
      var myTimerStop:Timer = new Timer(2000); // 2 seconds
      myTimerStop.addEventListener(TimerEvent.TIMER, throwDiceStop);
      myTimerStop.start();
  
      DiceOne.gotoAndStop(rollNum1);
      DiceTwo.gotoAndStop(rollNum2);
  }
  function throwDice():void {
      DiceOne.gotoAndPlay(0);
      DiceTwo.gotoAndPlay(0);
  }
  function throwDiceStop(event:TimerEvent):void {
      DiceOne.stop();
      DiceTwo.stop();
  }
  </code></pre>
  
  <p>But above statements won't work. Please tell me what am i missing here.</p>
  
  <p>Any helps would be awesome.</p>