Flash Bitmap and Spectrum Experiments

 

About the Experiments



This was my first attempt to learn Action Script and Flex.

I began by researching and implementing a way to do double buffered rendering directly on a Canvas (Flex Container).  Objects and states would render directly into a BitmapData buffer and when the render loop was done I copied every pixel from the BitMapData into the Canvas.

This has a disadvantage, you can’t use Flash’s display classes (Image, Sprite, Movie Clip) to draw your objects, you have to do it all manually, pixel by pixel. Loading and displaying images as bitmaps wasn’t complicated, but it made operations such as rotating and scaling very difficult (because I had to implement them myself).

However, this worked in my favor, because I originally implemented the Star-Field state by scaling bitmap images of 20*20 pixels. This brought my framerate down to about 20. But then I decided to try to draw the spheres myself manually and see what the performance difference was. I implemented a quick “drawCircle” function and my framerate shot straight to 100.

Working on the pixel level taught me some important skills: how to manipulate pixel data with matrices (to scale and rotate), and how I can get a massive performance boost by doing my own pixel coloring, instead of using images (which is essential in flash).

Full Source code is available for viewing and downloading.




Note: This is a Flex Project, so you will need to have the Flex SDK to be able to compile it.

Taken by CrazySam » Posted on May 14, 2010 » Filed in Flash » Link

Comments are closed.

Welcome

Hello and welcome to sambatista.com. My personal online game programming portfolio. Please feel free to look around and try any of my projects.



Follow me on Twitter!

Slideshow

Get the Flash Player to see the slideshow.