Smokescreen visualisation using Flash AS 3.0
I have been messing around a bit in Flash recently. I actually managed to learn many things about the new version of the ActionScript language (AS 3.0). Codewise, it is a huge improvement over AS 2.0 (one reason why I was never very fond of programming with Flash) but on the other hand quite tricky to understand at first. I still find it a little bit confusing. However, I did make something cool, so I am not totally lost.
Thanks to a number of useful tutorials over at gotoAndLearn() I was introduced to sound spectrums, bitmap filters and creating packages/classes in AS3.0. Of course I had to test myself to see if I had actually learned something. A music visualisation was the result!
Here is what it looks like (if the SWF file is buggy, please tell me how much I suck).
What it does is actually quite simple (once you’ve completed the previously mentioned tutorials, that is). Every time a frame is rendered it computes the sound spectrum. Flash has a function that does the comlicated stuff and then returns a set of values which describe how the sound is distributed in the frequency spectrum. Basically the same thing as those ‘jumping bars’ in your media player (or stereo). The visualisation plots this data on a bitmap object, which is then blurred and scrolled up depending on the overall volume. The process repeats itself over and over, which results in a smoke effect. Variations in volume usually create nice puffs of smoke.
I thought this was quite an interesting little project, so I created an ActionScript class which makes the visualisation easy to reuse in other Flash applications. Admittedly, this is my first well-structured ActionScript code ever. Please have a look at it and then proceed to critise my attempt at programming in the comments.
If you happen to like my creation and want to put it to good use, you can download the AS3.0 package. You are free to use and modify it without any limitations, but please let me know in case it’s a public project.
The music in the demo was made by PriZm at OC ReMix. A great website by the way.
Vincent on May 4th, at 7:59 pm •