As3cards provides a skinnable card engine for creating playing card games. The project hasĀ an example implementation of Klondike Solitaire.

Sample

        /**
         * Creates the initial layout for the game, sets up the
         * card piles but does not deal.
         */
        private function createBoard():void
        {
                // TODO: Get board dimensions from a style manager?
                visualDeck = new VisualDeck( DeckType.WITHOUT_JOKERS );
                visualDeck.x = 0;
                visualDeck.y = 0;
                addChild( visualDeck );

                // TODO: Use a factory to get the dealtPile based on the
                // user's deal settings (deal one vs. deal three)
                dealtPile = new DealOnePile();
                dealtPile.x = 90;
                dealtPile.y = 0;
                addChild( dealtPile );

                // Store references to the Klondike piles
                klondikePiles = new Array();
                var curX:int = 0;
                var curY:int = 100;
                // There are 7 Klondike piles to create
                for ( var i:int = 0; i < 7; i++ )
                {
                        var kp:KlondikePile = new KlondikePile();
                        kp.x = curX;
                        kp.y = curY;
                        // Saves the reference
                        klondikePiles.push( kp );
                        // Add the pile to the screen
                        addChild( kp );
                        // Move the next pile 90 to the right
                        curX += 90;
                }

                acePiles = new Array();
                curX = 90*3;
                curY = 0;
                // There are 4 Ace piles to create
                for ( i = 0; i < 4; i++ )
                {
                        var ap:AcePile = new AcePile();
                        ap.x = curX;
                        ap.y = curY;
                        // Save the reference
                        acePiles.push( ap );
                        // Add the pile to the screen
                        addChild( ap );
                        // Move the next pile 90 to the right
                        curX += 90;
                }
        }

        /**
         * Deals the cards from the deck into the klondike piles
         */
        private function dealCards():void
        {
                // First, shuffle the deck
                visualDeck.shuffle();

                // Deal rows horizontally
                for ( var i:int = 0; i < 7; i++ )
                {
                        // Flip over the first card, deal the rest face down
                        var card:VisualCard = new VisualCard( visualDeck.deal(), false );
                        // Set up the card for drag and drop
                        configureDrag( card );
                        // Add the card to the pile
                        klondikePiles[i].addCard( card );

                        // Add face down cards to all of the card piles on the right of this one
                        for ( var j:int = i + 1; j < 7; j++ )
                        {
                                klondikePiles[j].addCard( new VisualCard( visualDeck.deal(), true ) );
                        }
                }
        }
Misc . URL.