Solarium

Code sample

This script extract shows how sound amplitude values are translated into moving bars of colour
// define the sound amplitude array (smoothed)
amplitude = new Array(0, 0, 0, 148, 295, 414, 388, 372, ...);

// attach the barholder movie clip
attachMovie("barholder", "barholder", 1);

function dance()
{
  // get the current frame and amplitude
  frame = _currentframe - 1;
  amp   = amplitude[frame];

  // handle missing amp values
  if (amp == undefined) amp = 0;

  // make the solar ball dance
  ball._xscale = amp; ball._yscale = amp;

  // paint a new bar
  barholder.attachMovie("bar", "bar" + frame, frame);
  target = eval("barholder.bar" + frame);

  // adjust the bar width to match the amplitude
  target._xscale = amp;

  // move the bar up
  target._y = -frame;

  // move the barholder down, to keep the bar centered
  barholder._y = frame;
}