Here's a little game I've been working on - Solitaire (Klondike) - written using an ActionScript3-only project in FlexBuilder 2.
ActionScript 3 Solitaire (requires Flash Player 8.5 to view).
I'm not entirely sure what I want to do with this code yet. I think I'll be placing it inside of IFBIN but it doesn't really belong in Flex By Example since it's not a Flex project. Additionally, it's not really a Flash project because Flash doesn't have ActionScript 3 support yet so at the moment it doesn't really belong in Flash By Example. I think what I might do is create a Flex 2 shell for the game with a classic menubar and an options panel to configure scoring, deal 1 vs. deal 3 and the card/deck skin, and then add the whole thing into Flex By Example.
This is a great example to use as a starting point for other card games going forward. I've created a generic card engine that is completely skinnable and can easily be extended to create other games (such as FreeCell, Poker, etc). The game features a modular Object-Oriented architecture, so the core card engine can easily be dropped into a game and function without issue. Creating FreeCell from this example is just a matter of changing the game rules since everything else can be re-used.
This is also a good example of using the new DisplayList API. Whenever you drag some cards around, there's no need to worry about depth management or attaching and removing MovieClips to achieve the effect (things we had to worry about with ActionScript 2). Instead, just re-parent the cards and magically they're on top of everything. When the cards are dropped, re-parent the cards again, and magically they're attached elsewhere. I'm really diggin' the new DisplayList.
There are still some things not done - for instance, there's no scoring, and there's no super-cool end game animation sequence (or even a message that tells you you win). However, the game is fully playable, and capable of wasting hours of your life at a time if you let it.
Enjoy!

12 Comments
Any other requirements besides FP 8.5? I tried to load it up (FP 8.5, Safari, OS 10.4), and got a load of alert boxes with errors, and then nothing loaded up.
Posted by: Patrick | December 19, 2005 10:27 AM
Darron, it looks like the link is a bit foobarred on my version of the 8.5 player under Firefox / Win XP
I get the following errors:
VerifyError: Error #1042: Not an ABC file. major_version=46 minor_version=15
ReferenceError: Error #1065: Variable DefaultSkin_EightHearts is not defined
ReferenceError: Error #1065: Variable DefaultSkin_JackHearts is not defined
And it continues until you 'dismiss all' in the error dialog. Hope it's just me
FG
Posted by: FlashGen | December 19, 2005 10:33 AM
The same for me...
Posted by: Quentin | December 19, 2005 10:36 AM
My bad - I'm fixing it now.. sorry for the hiccup!
Posted by: darron | December 19, 2005 10:39 AM
Fixed now. I built the final file with some configuration options that aren't supported just yet, so I had to rebuild with the options missing and then re upload.
Posted by: darron | December 19, 2005 10:49 AM
Works fine, great work !
Posted by: Quentin | December 19, 2005 11:10 AM
hey man, nice work.
finished playing and missed the jumping cards -effects at the end though ;-)
Posted by: spif | December 19, 2005 11:14 AM
very nice!!
Posted by: zikey | December 20, 2005 7:01 AM
Any chance at getting access to the source other than through a $500.00 portal?
Posted by: Jaks | February 1, 2006 10:32 AM
Updated URL is here: http://www.darronschall.com/playground/klondike2.html
Requires latest Flash Player 8.5 from labs.macromedia.com.
Posted by: darron | February 11, 2006 9:52 PM
@Jaks - The code is in Flex By Example, which is available for US$250. If you'd like to purchase the Klondike code separately, it's US$50.
Posted by: darron | March 16, 2006 10:52 AM
If anyone happens to stumble across this page, head over to here instead: http://www.darronschall.com/weblog/archives/000264.cfm
The above link is my announcement that this is an open source project, with download links as well as an updated example application.
Posted by: darron | June 15, 2007 10:31 AM