title: Action Script 3. How to add timer?
body: <p>I'm creating Flash "memory" game, Idea to discover 2 equal cards. But when I choose 1, if second card is wrong It discover only for half second, but this is not enough. I need to make that second card will be shown for 2-3 seconds. How can I add timer?</p>
  
  <p>Here is part of code:</p>
  
  <pre><code>        else
          {
              trace("wrong");
              _message = "wrong";
              message_txt.text = _message;
              _firstCard.gotoAndPlay("flipBack");
              event.currentTarget.gotoAndPlay("flipBack");
              _firstCard.addEventListener(MouseEvent.CLICK, checkCards);
              event.currentTarget.addEventListener(MouseEvent.CLICK, checkCards);
              _firstCard = undefined;             
          }
  </code></pre>
  
  <p>Thank you for answers.</p>
  
  <p><strong>UPDATED WITH FULL CODE</strong></p>
  
  <pre><code>package
  {
      import flash.display.MovieClip;
      import Card;
      import Boarder;
      import BlueBoard;
      import flash.events.MouseEvent;
      import RedBoard;
      import Snow;
  
      public class MemoryGame extends MovieClip
      {
          private var _card:Card;
          private var _boarder:Boarder;
          private var _blueBoard:BlueBoard;
          private var _cardX:Number;
          private var _cardY:Number;
          private var _firstCard:*;
          private var _totalMatches:Number;
          private var _currentMatches:Number;
          private var _redBoard:RedBoard;
          private var _snow:Snow;
          private var _cards:Array;
          public var  _message:String;
  
          public function MemoryGame()
          {
              _cards = new Array();
              _totalMatches = 4;
              _currentMatches = 0;
              createCards();
          }
  
          private function createCards():void
          {
              _cardX = 45;
              _cardY = 10;
  
              for(var i:Number = 0; i &lt; 2; i++)
              {
                  _card = new Card();
                  addChild(_card);
                  _boarder = new Boarder();
                  _card.setType(_boarder);
                  _card.x = _cardX;
                  _card.y = _cardY;
                  _cardX += _card.width + 50;
                  _card.addEventListener(MouseEvent.CLICK, checkCards);
                  _cards.push(_card);
              }
  
              for(var j:Number = 0; j &lt; 2; j++)
              {
                  _card = new Card();
                  addChild(_card);
                  _blueBoard = new BlueBoard();
                  _card.setType(_blueBoard);
                  _card.x = _cardX;
                  _card.y = _cardY;
                  _cardX += _card.width + 50;
                  _card.addEventListener(MouseEvent.CLICK, checkCards);
                  _cards.push(_card);
              }
  
              _cardX = 45;
              _cardY = _card.height + 30;
  
              for(var k:Number = 0; k &lt; 2; k++)
              {
                  _card = new Card();
                  addChild(_card);
                  _redBoard = new RedBoard();
                  _card.setType(_redBoard);
                  _card.x = _cardX;
                  _card.y = _cardY;
                  _cardX += _card.width + 50;
                  _card.addEventListener(MouseEvent.CLICK, checkCards);
                  _cards.push(_card);
              }
  
              for(var l:Number = 0; l &lt; 2; l++)
              {
                  _card = new Card();
                  addChild(_card);
                  _snow = new Snow();
                  _card.setType(_snow);
                  _card.x = _cardX;
                  _card.y = _cardY;
                  _cardX += _card.width + 50;
                  _card.addEventListener(MouseEvent.CLICK, checkCards);
                  _cards.push(_card);
              }
  
              randomizeCards(_cards);
          }
  
          private function checkCards(event:MouseEvent):void
          {
              event.currentTarget.removeEventListener(MouseEvent.CLICK, checkCards);
  
              if(_firstCard == undefined)
              {
                  _firstCard = event.currentTarget;
              }
              else if(String(_firstCard._type) == String(event.currentTarget._type))
              {
                  trace("match");
                  _message = "match";
                  message_txt.text = _message;
                  _firstCard = undefined;
                  _currentMatches ++;
                  if(_currentMatches &gt;= _totalMatches)
                  {
                      trace("YOU WIN !!!");
                      _message = "YOU WIN !!!";
                      message_txt.text = _message;
                  }
              }
              else
              {
                  trace("wrong");
                  _message = "wrong";
                  message_txt.text = _message;
                  _firstCard.gotoAndPlay("flipBack");
                  event.currentTarget.gotoAndPlay("flipBack");
                  _firstCard.addEventListener(MouseEvent.CLICK, checkCards);
                  event.currentTarget.addEventListener(MouseEvent.CLICK, checkCards);
                  _firstCard = undefined;             
              }
          }
  
          private function randomizeCards(cards:Array):void
          {
              var randomCard1:Number;
              var randomCard2:Number;
              var card1X:Number;
              var card1Y:Number;
  
              for(var i:Number = 0; i &lt; 10; i++)
              {
                  randomCard1 = Math.floor(Math.random() * cards.length);
                  randomCard2 = Math.floor(Math.random() * cards.length);
  
                  card1X = cards[randomCard1].x;
                  card1Y = cards[randomCard1].y;
                  cards[randomCard1].x = cards[randomCard2].x;
                  cards[randomCard1].y = cards[randomCard2].y
                  cards[randomCard2].x = card1X;
                  cards[randomCard2].y = card1Y;
              }
          }
      }
  }
  </code></pre>