Quantcast
Channel: Adobe Community : All Content - Adobe Animate CC - General
Viewing all articles
Browse latest Browse all 13519

Shuffle Deck of Cards

$
0
0

Hi I am trying to deal a deck of cards to four players so each player has 13 cards I have found some forums and websites with information but I can't seem to get it working and I hope someone can help me http://books.google.ie/books?id=CKJ7Mc_gKTwC&pg=PA437&lpg=PA437&dq=dea l+deck+of+cards+with+actionscript&source=bl&ots=pqhXzDUSaB&sig=0SP16q9 vFHGtk6JteawS-iJbvW8&hl=en&sa=X&ei=fY3rUv7BHeWy7Aar8IGgDw&ved=0CGgQ6AE wCQ#v=onepage&q=deal%20deck%20of%20cards%20with%20actionscript&f=false This is the example I am trying to follow. I imported the images the same way as shown in this video on YouTube

 

http://www.youtube.com/watch?v=hxkIxqdfApE

 

The error I get is type not found or was not compile time constant CARD my code is exactly the same as the first link. I also found this website http://www.flashandmath.com/howtos/carddeal/ I think its fair to say I have done my homework and Its probably something really simple

 

package

{

     import flash.display.*;

     import flash.events.*;

    

 

     public class HelloBridge extends MovieClip

     {

 

          const OFFSET:int=45;

          const CARDWIDTH: int=80;

          const CARDBACK: int=54;

          const SUITS:Array=new Array("CLUBS","DIAMONDS","HEARTS","SPADES");

          const RANKS:Array=new Array("TWO",THREE","FOUR","FIVE","SIX","SEVEN","EIGHT","NINE","TEN"," JACK","QUEEN","KING","ACE");

 

          var deck:Array = new Array();

          var deckIndexes:Array = new Array();

    

          public function HelloBridge():void

          {

 

               constructDeck(deck, deckIndexes);

               btnDeal.addEventListener(MouseEvent.CLICK, shuffleDeck);

          }

    

          function constructDeck():void

          {

 

               var cardObj:Card;

               for (var i:uint = 0;  i < 52; i++) {

               cardObj=new CARD;

               cardObj.scaleX=cardObj.scaleY=.4;

               cardObj.Suit=SUITS[Math.floor(i/13)];

               cardObj.Value=i%13+1;

               cardObj.Rank=RANKS[cardObj.Value-1];

               if cardObj.Value==9) {

                    cardObj.Value = 1;

               }

               cardObj.faceUp=true;

               cardObj.frameIndex=i+1;

               cardObj.gotoAndStop(i+1);

               cardObj.addEventListener(MouseEvent.CLICK, cardClicked);


Viewing all articles
Browse latest Browse all 13519

Trending Articles