The Flash platform has always had a controversial relationship with the Web. Flash was rightfully ruled out as a web design tool. In recent years Flash became the standard for video delivery on the Web. The emergence of HTML5, however, might just be the factor that will push Flash out of its niche and make video inherent to the Web. Nevertheless, Flash remains a powerful tool for visualizations and game applications. Here are some of my Actionscript 3 projects.
Bezier Curves Interactive Visualization
Bezier curves, invented by french engineer Pierre Étienne Bézier, play a crucial role in the world of computer graphics (and not only). Understanding how Bezier curves work can be mind-boggling if you just stare at the neat little formula that is used to describe them. Therefore, I created an interactive visualization that describes the mechanical meaning of the formula. You can read more about this project and get the source code here.
Water World Project
During my last semester of my MSc Digital Media course I took a course in Programming Principles for 2D/3D Animation. It gave me the chance to explore further Object Orientation and other aspects of Ationscript 3.0. The Water World project provided an opportunity for me to look into different ways for collision detection with AS3. Apart from the built in hitTestObject method I also tried a couple of bitmap based pixel-precise methods including the Collision Detection Kit for AS3. I also experimented with different ways to implement those methods. Below are two of the main ones.
Warning: The two applications below are still in development and, although there should be no bugs, there is nothing to limit the number of objects you put on the stage. So, if you put too many objects, your computer might crash. The big red button saying TEST creates 400 Algons on the stage. I have tested the application with around 1500 of them before it seriously slows down. I would recommend you read the project description before testing those out.
- You can plant Algons by clicking in the water (or you can plant 400 all at once by clicking the TEST button.
- The Algons replicate with a rate that depends on the Nutrition level, which you can adjust. You can see the "bioclock" of each Algon to see how often it replicates.
- You can put a Zoon with the yellow button. The Zoon starts feeding on the Algons. If you increase the light level, the Zoon will sense the Algon when it gets closer to it.
- The Zoon replicates if it has eaten 5 Algons and it dies if it has not eaten for 10 seconds.
Distance based collision detection using vectors
In this case each of the Zoons (the red creatures) has an internal vector in which it stores a list of objects (the Algons) to check for collision with. The list is updated everytime an Algon is added or removed from the stage. The Zoon checks for collision only within a certain radius.
click on the image to launch the application (requires Flash PLayer 10).
Collision detection using a grid
Here the collision detection is implemented using a grid. Each cell of the grid has a vector containing all objects within it. Each frame the Zoon is aware which cell it is in and therefore checks for collision only with objects in the neighbouring cells. Although the number of performed checks dropped significantly, the process of updating the grid ended up quite expensive, thus providing similar performance to the first one.