3 Replies Latest reply on Nov 20, 2007 12:04 PM by Damon Edwards

    Hi, I need a help with this code.

    JonFM
      Hi, I need help. Can somebody please help me with this code.
      Hi, everybody, I'm new in these forums, I have been visiting this forum for a while but finally I have registered!

      I am learning actionscripting and I'm having a problem with the last part of my project:

      can somebody please tell me how I can make this code make my cards change only once, like I only click on the cards once and not change anymore after you click on all five once: Thank you, here is my code so far:


      function randomI(N){
      //return numbers 0 up to N - 1
      return Math.floor( (N )* Math.random());
      }
      var cards:String= "joker#ace#deuce#three#four#five#six#seven#eight#n ine#ten#jack#queen#king"
      var cardArrayName:Array = new Array();
      var cardArray:Array = new Array();// put Card object movieclips
      cardArrayName = cards.split("#");
      newSpace =32;
      newSpaceY=6;

      for(i=0;i<5;i++){
      newLevel= _root.getNextHighestDepth();
      cardArray = _root.attachMovie("Card","cardObject"+newLevel,new Level);
      var colorObject:Color=new Color(cardArray
      .bg);
      colorObject.setRGB(0xff0000);
      pickIndex=randomI(cardArrayName.length);
      cardArray .cardName = cardArrayName.splice(pickIndex,1);
      cardArray
      ._y =newSpaceY;
      cardArray ._x = newSpace;
      newSpace += 72+32;
      cardArray
      .onPress = function() {

      this.startDrag(false);

      }
      cardArray .onRelease= cardArray.onReleaseOutside = function() {

      this.stopDrag();
      }
      if(i==4){
      newSpace=32;
      newSpaceY+=6+125;
      }
      if(i==9){
      newSpace=32;
      newSpaceY+=6+125;
      }

      }// end of loop

      var click:Boolean = true;
      cardArray[0].onPress = function(){
      if ( click == false) {
      click = true;}
      else{

      click = false;
      }
      trace(click);
      }

      cardArray[0].onPress = function(){
      trace(cardArray);
      pickIndex=randomI(cardArrayName.length);
      cardArray[0].cardName = cardArrayName.splice(pickIndex,1);
      }


      cardArray[1].onPress = function(){
      trace(cardArray);
      pickIndex=randomI(cardArrayName.length);
      cardArray[1].cardName = cardArrayName.splice(pickIndex,1);

      }


      cardArray[2].onPress = function(){
      trace(cardArray);
      pickIndex=randomI(cardArrayName.length);
      cardArray[2].cardName = cardArrayName.splice(pickIndex,1);

      }
      cardArray[3].onPress = function(){
      trace(cardArray);
      pickIndex=randomI(cardArrayName.length);
      cardArray[3].cardName = cardArrayName.splice(pickIndex,1);

      }
      cardArray[4].onPress = function(){
      trace(cardArray);
      pickIndex=randomI(cardArrayName.length);
      cardArray[4].cardName = cardArrayName.splice(pickIndex,1);

      }