Posts Tagged ‘programming’

Sound visualizer in Flash

Tuesday, April 28th, 2009

Per Kristian Stoveland held a cool presentation of his Sound Spectrum Analyzer at FUGN (Flash user group Norway) in the beginning of April. Inspired by this session I decided to try this my self.
I remembed seeing a beutifull graphic called “Imagination” made by Paul Neave, which he also had released as open source. So I grabbed my copy of it and tweaked a little bit and instead of mouse interaction I hooked it up with the SoundMixer.computeSpectrum() in Flash. I turned out pretty cool I think!
This is my first attempt so there will be more to come. The source code need to be cleaned up so I will release it later. The awesome soundtrack is by virgill & tasium.

Check it out!

soundvisualizer

Change the numeric values of two variables without a temp variable

Sunday, August 31st, 2008

I found a nice way to change the numeric values of two variables without the use of a temporary variable. It goes like this:

 
// set up two variables to play with
var value1:Number = 10;
var value2:Number = 20;
 
trace("values before");
trace("value1 = " + value1);
trace("value2 = " + value2);
 
// change values
value1 = value1 + value2; // value1 = 30
value2 = value1 - value2; // value2 = 30 - 20 = 10
value1 = value1 - value2; // value1 = 30 - 10 = 20
 
trace("values after");
trace("value1 = " + value1);
trace("value2 = " + value2);

It works with all kind of numbers I can think of both negative and positive integers and floting point numbers