Mandelbrot fractal viewer in Flash Actionscript 3

Geek that I am, I have always been fascinated with the Mandelbrot set for as long as I can remember. I spent hours and hours as a kid viewing it on Fractint on my dad’s 486 and subsequently have written viewers in C# .Net, TurboPascal, Silverlight, Java, JavaScript, BBC Basic and the Casio 7400g. Having recently done a lot of work with Flash, I decided to try one in ActionScript 3.

Below is the latest version of the application. Click to zoom.

Flash 10 required!

The panel on the right controls the rate of zoom, the lower middle panel controls the iteration bailout value (set this to higher when zooming to stop smaller fractals appearing ‘blobby’) and the lower left panel controls the palette cycling mode (N.B. this is still a bit glitchy but I hope to improve on this)

I discovered that there were some unexpected pay offs in using ActionScript:

  • The zoom function was extremely easy to program using the inbuilt Flash tween classes.
  • Palette cycling. The early version of the fractal browsers that I have used had some kind of palette cycle mode. When implementing this project, I discovered the paletteMap() function of the bitmapData class and this demonstration. However the documentation of the function isn’t that in-depth, as such this is an early version of the palette cycling mode. I hope to soon fully understand how the palette map function works, and to post an explanation.
  • Little touches to the user interface are very easy to create (although possibly much easier using Flex)

As well as some hindrances:

  • The lack of real threading in AS 3 makes it hard to code. Basically, because the process of generating the fractal takes quite a long time, it locks up the application whilst this is running. The method I used for working round this was to pause the calculation every so often using the setInterval() method to wait (which would give the graphics time to re-render)
  • No useful built in collection framework in AS 3 and I didn’t reuse an existing collection framework because the object of the exercise was coding it all myself, however I hope to refactor this soon.

Tags: ,

Comments are closed.