title: ActionScript3 : Argument Error on constructor
body: <p>I have a real problem on an ActionScript homework. I have to program a solitaire, and I'm now stuck on a bug that I don't understand.
  When I launch my game object, it instanciates a CardDeck object, and fill its array with Card objects. But since my last edit, a "ArgumentError: Error #1063" is thrown every 2 seconds, and i just don't get why. I've looked and tried the few topics related to this Error, but I didn't manage to make it work ...</p>
  
  <p>Here are my classes :</p>
  
  <ul>
  <li><p>Card.as</p>
  
  <pre><code>import flash.display.MovieClip;
  import flash.events.Event;
  import flash.events.MouseEvent;
  import flash.display.*;
  import flash.events.TimerEvent;
  import flash.utils.Timer;
  
  public class Card extends MovieClip
  {
  public static const COLOR_RED:int = 1;
  public static const COLOR_BLACK:int = 2;
  
  public static const SYMBOL_HEART:int = 1;
  public static const SYMBOL_DIAMOND:int = 2;
  public static const SYMBOL_SPADE:int = 3;
  public static const SYMBOL_CLUB:int = 4;
  
  public var game:Game;
  
  private var t:Timer; // For click/double click fix
  private var currentTarget:Card;
  
  public var container:CardStack;
  public var color:int;
  public var symbol:int;
  public var value:int;
  public var isVisible:Boolean = false;
  
  public function Card(type:int, value:int, g:Game) 
  {
      game = g;
  
      if (type == SYMBOL_HEART || type == SYMBOL_DIAMOND)
          this.color = COLOR_RED;
      else
          this.color = COLOR_BLACK;
  
      this.symbol = type;
      this.value = value;
  
      this.doubleClickEnabled = true;
      this.addEventListener(MouseEvent.CLICK, Click);
      this.addEventListener(MouseEvent.DOUBLE_CLICK, doubleClick);
  }
  
  private function doubleClick(e:MouseEvent):void 
  {
      t.removeEventListener(TimerEvent.TIMER_COMPLETE, onCardClick);
      if (t.running)
          t.stop();
      onCardDoubleClick(e);
  }
  
  private function Click(e:MouseEvent):void 
  {
      currentTarget = (Card)(e.currentTarget);
      t = new Timer(100,1);
      t.addEventListener(TimerEvent.TIMER_COMPLETE, onCardClick);
      t.start();
  }
  
  
  public function isSameColor(otherCard:Card):Boolean
  {
      if (this.color == otherCard.color)
          return true;
      else
          return false;
  }
  
  public function setVisible(flipped:Boolean):void 
  {
      if (flipped == true)
      {
          isVisible = true;
          gotoAndStop(value);
      }
      else {
          isVisible = false;
          gotoAndStop(14);
      }
      game.pStage.addChild(this);
  }
  
  public function setInvisible():void
  {
      removeListeners();
      game.pStage.removeChild(this);
  }
  
  public function removeListeners():void 
  {
      this.removeEventListener(MouseEvent.CLICK, Click);
      this.removeEventListener(MouseEvent.DOUBLE_CLICK, doubleClick);
  }
  
  private function onCardClick(e:TimerEvent):void 
  {
      var card:Card = currentTarget;
  
      if (this.isVisible == true) {
          if (game.flagSelecting == false) {
              if (!(card.container == game.deck &amp;&amp; game.deck.isHeadCard(card) == false))
                  game.select.addToSelect(card);
          }else{
              if (card.container == game.deck)
                  game.deck.lastPickedCard--;
  
              game.mvOutCard(game.select.tSelect, card.container);
          }
      }else {
          if (((card.container.deckSize()) - 1) == (game.selCard(card, card.container)))
              card.setVisible(true);
      }
  }
  
  private function onCardDoubleClick(e:MouseEvent):void 
  {
      var card:Card = (Card)(e.currentTarget);
  
      // Acestack
      if (game.aceStacks.canMoveTo(card) == true)
      {
          game.moveToAce(card);
      }
  
      //K sur place libre
      if (card.value == 13) {
          var freeStack:CardStack = (game.river.hasFreeStack());
  
          if (freeStack != null){
              game.select.addToSelect(card);
              game.moveKing(game.select.tSelect, freeStack);
          }       
      }
  
      game.select.reinitSelection();
          }
  
  }
  </code></pre></li>
  <li><p>CardDeck.as</p>
  
  <pre><code>import Math;
  import flash.events.MouseEvent;
  import flash.events.Event;
  
  public class CardDeck extends CardStack
  {
          // THIS IS ABOUT CARDDECK
          public var lastPickedCard:int = 0;
  public var isEmptyNow:Boolean = false;
  
  // THIS IS ABOUT HANDSTACK
  public var handStack:Array = new Array();
  
  public static const X_FIRST_HANDCARD:int = 120;
  public static const X_CARD_PADDING:int = 18;
  public static const Y_HANDSTACK:int = 62;
  
  public function CardDeck(g:Game) 
  {
      trace("GAME" + g);
      var a:Array = new Array();
      var nGame:Game = g;
      super(a,g); 
      trace("CONSTRUCTEUR2");
      var i:int = 1;
  
      while (i &lt;= 52)
      {
          if (i &lt; 14)
              this.deck.push(new HeartCard(i,g));
          else if (i &gt;= 14 &amp;&amp; i &lt; 27)
              this.deck.push(new DiamondCard(i - 13, g));
          else if (i &gt;= 27 &amp;&amp; i &lt; 40)
              this.deck.push(new SpadeCard(i - 26, g));
          else if (i &gt;= 40)
              this.deck.push(new ClubCard(i - 39, g));
  
          i++;
      }
  
      trace("CONSTRUCTEUR3");
      var nDeck:Array;
      nDeck = new Array();
      var idx:int;
  
      while(this.deck.length &gt; 0){
          var r:int = Math.random()*(this.deck.length);
          idx = (Math.floor(r));
          //deck[idx].container = game.deck;
          nDeck.push(deck.splice(idx, 1)[0]);
      }
  
      trace("CONSTRUCTEUR4");
      this.deck = nDeck;
  
      this.addEventListener(MouseEvent.CLICK, onDeckClick);
  
      this.game.pStage.addChild(this);
      this.x = 46;
      this.y = 62;
      trace("CONSTRUCTEUR5");
  }
  
  private function onDeckClick(e:MouseEvent):void 
  {
      trace("LISTENER");
      if (isEmptyNow == false)
          fillHand();
      else
          setFilled();
  }
  
  public function setEmpty():void 
  {
      this.alpha = .2;
      this.isEmptyNow = true;         
  }
  
  public function setFilled():void
  {
      this.alpha = 1;
      this.isEmptyNow = false;
      this.reinitHS();
  }
  
  
  // HANDSTACK
  public function showHand():void
  {
      var i:int = 0;
  
      while (i &lt; (this.handStack.length)) {
          trace("SHOW HAND");
          handStack[i].setVisible(true);
          handStack[i].y = Y_HANDSTACK;
          handStack[i].x = X_FIRST_HANDCARD + (i * X_CARD_PADDING);
          i++;
      }
  
      this.setDepth();
  }
  
  public function fillHand():void
  {
      trace("FILL");
      if(lastPickedCard &lt; (deck.length)-3)
          this.handStack = this.deck.slice(deck.lastPickedCard, 3);
      else {
          this.handStack = this.deck.slice(game.deck.lastPickedCard);
          this.setEmpty();
      }
  
      showHand();
  }
  
  
  public function reinitHS():void {
  
      var i:int = 0;
  
      while (i &lt; (this.handStack.length)) {
          handStack[i].setInvisible();
          i++;
      }
  
      this.handStack = new Array();
  }
  
  public function isHeadCard(c:Card):Boolean
  {
      if (handStack.indexOf(c) == handStack.length -1)
          return true;
      else
          return false;
  }
  }
  </code></pre></li>
  <li><p>CardStack.as</p>
  
  <pre><code>    import flash.display.MovieClip;
  
      public class CardStack extends MovieClip
      {
              public var deck:Array;
  
              public var game:Game;
  
              public function CardStack(newDeck:Array, g:Game)
              {
          game = g;
          this.deck = newDeck;
      }
  
  public function isEmpty():Boolean {
  
      if (this.deck.lenght == 0)
          return true;
      else
          return false;
  }
  
  public function setDepth():void 
  {
              var i:int = 0;
              while (i &lt; (this.deck.length))
              {
                      if (i == 0)
                              this.deck[i].parent.setChildIndex(this.deck[i], 1);
                      else
                              this.deck[i].parent.setChildIndex(this.deck[i], 1 + i);
          i++;
      }
  
  }
  
  public function deckSize():int {return (this.deck.length);} 
  
  }
  </code></pre></li>
  </ul>
  
  <p>I call this here :</p>
  
  <pre><code>    public function Game(pS:Stage)
      {
          pStage = pS;
  
          select = new Selection(this);
  
          trace("flag");
          deck = new CardDeck(this);
          trace("flag2");
          aceStacks = new AceRiver(this);
  
          river = new River(deck.deck, this);
      }
  </code></pre>
  
  <p>And I get this exception :</p>
  
  <pre><code> ArgumentError: Error #1063: Argument count mismatch on CardDeck(). Expected 1, got 0
  </code></pre>
  
  <p>Any help would be really appreciated !</p>