The Effect and Comments

The card trick uses a packet of four cards with one initially reversed. The user is allowed to "shuffle" the packet. Regardless of the amount of shuffling, the suit of the card that will be reversed with respect to the others in the end is predicted and displayed ahead of time. Works great on Android 2.2! Click the screen shot below or this link to open the effect in a new window and watch the magic:


  • Download all source files corresponding to this effect:

Comments, Custom AS3 Classes

There are several custom AS3 classes behind the effect that are very useful for applications involving playing cards: CardDeck, PlayingCard, and ImageLoader. You will find the classes in the zip package above.

The ImageLoader class allows you to load card images at rutime concurently rather than consecutively. The CardDeck class organizes the packet of cards that you are using (it can be the whole deck). All the actions of flipping, shuffling, and cutting cards are accomplished through public methods of the PlayingCard class.

The magic trick illustrated below was featured in the article, "Invariants under Group Actions to Amaze your Friends," which appeared in Mathematics Magazine, December 1999.

The card images used in our example were created by Jesse Fuchs and Tom Hart from free SVG images created by David Bellot, and are themselves available for use under a Creative Commons License.

Back to Flash CS4 Tutorials              Back to Flash and Math Home

We welcome your comments, suggestions, and contributions. Click the Contact Us link below and email one of us.

Adobe®, Flash®, ActionScript®, Flex® are registered trademarks of Adobe Systems Incorporated.