rendered paste bodyvar s:Sound = new Sound();
var sc:SoundChannel;
var ba:ByteArray = new ByteArray();
var array:Array = new Array();
//Security.allowDomain('www.skymarshallarts.com');
s.load(new URLRequest("fade.mp3"));
//s.addEventListener(flash.events.Event.ID3, onID3);
sc = s.play(0, 1000);
this.addEventListener(Event.ENTER_FRAME, spectrum);
function RGBToHex (r, g, b ){
var hex = r << 16 ^ g << 8 ^ b;
return hex;
}
function wr(i:Number){
if(i > 255){
return 255-(i%255);
} else{
return i;
}
}
function Deg2Rad(deg){
return deg*Math.PI/180;
}
var a:Number = 0;
function spectrum(event:Event)
{
a = 0;
var max:Number = 0;
graphics.clear();
SoundMixer.computeSpectrum(ba, false, 0);
graphics.moveTo(0, 600);
for(var i=0; i<512; i+=4)
{
var an:Number = (i/512)*360;
b = ba.readFloat();
a = Math.abs((b * 300));
graphics.lineStyle(1, RGBToHex(255, wr(i), 0));
graphics.moveTo(256, 300);
graphics.lineTo(Math.sin(Deg2Rad(an))*a+256, Math.cos(Deg2Rad(an))*a+300);
max = Math.max(max, a);
}
}