So, over the past few months, I’ve collected a rather large set of examples that I have used in various classes, presentations and how-tos. They’ve been sitting on my hard drive, rotting for the most part, so I’ve decided to post them on my blog.
All the examples that I will be posting over the next few weeks (as I get time to clean them up and make them pretty) have the "Right-Click -> View Source" enabled. I encourage you to download the samples and play with them. I’ve opened up the licensing on them so you can pretty much whatever you want with them (although, if I see my name in a book, or credit in a cool applicaiton, I might giggle like a school girl) 🙂
The first example I’m posting is a "Life Simulator". It’s not as cool as it sounds, but it is based on the 1970’s works of the British mathematician John Horton Conway. His game (the Game of Life) is one of the best-known examples of cellular automation.
It is also considered a "zero player" game. You set up the seed of the game (by hitting Randomize), and then watch it go (watching it go, means starting the timer). The cells will follow the rules of the game and show their results on the screen. The rules, as per this wikipedia article state :
The universe of the Game of Life is an infinite two-dimensional orthogonal grid of square cells, each of which is in one of two possible states, live or dead. Every cell interacts with its eight neighbours, which are the cells that are directly horizontally, vertically, or diagonally adjacent. At each step in time, the following transitions occur:
- Any live cell with fewer than two live neighbours dies, as if by loneliness.
- Any live cell with more than three live neighbours dies, as if by overcrowding.
- Any live cell with two or three live neighbours lives, unchanged, to the next generation.
- Any dead cell with exactly three live neighbours comes to life.
This example shows how to use some of the basic "native" graphics capabilities in Flex, how to extend a component to make your own, and a good example of the seperation of the business layer and the display layer (the model is baked into the business layer in this example because of its simplicity).
Check it out and let me know what you think!!