ForumsProgramming ForumAdobe Flash Music Visualization Help

16 13248
jpx111
offline
jpx111
264 posts
Nomad

Hello fellow Flash users
Today, I was exploring the world of music visualization in flash and i came across a good tutorial thingy...i was modifying it and changing numbers around and i got a pretty cool effect ...except you see, the whole thing is done on AS3 and doing a whole project on codes isn't my thing... I have a doubt...but first let me show you the script:

var url:String = "Mas Que Nada.mp3";
var request:URLRequest = new URLRequest(url);
var s:Sound = new Sound();
s.addEventListener(Event.COMPLETE, completeHandler);
s.load(request); var song:SoundChannel = s.play();
song.addEventListener(Event.SOUND_COMPLETE, soundCompleteHandler);
var ba:ByteArray = new ByteArray();

var gr:Sprite = new Sprite();
gr.x = 150;
gr.y = 400;
var blur:BlurFilter = new BlurFilter(10,20, BitmapFilterQuality.HIGH);
gr.filters = [blur];
addChild(gr);



var time:Timer = new Timer(50);
time.addEventListener(TimerEvent.TIMER, timerHandler);
time.start();

function completeHandler(event:Event):void {
event.target.play();
}

function soundCompleteHandler(event:Event):void {
time.stop();
}


function timerHandler(event:TimerEvent):void {
SoundMixer.computeSpectrum(ba,false);
var i:int;
gr.graphics.clear();
var mat:Matrix = new Matrix();
mat.rotate(1.57079633);
gr.graphics.beginGradientFill(GradientType.LINEAR, [0xFF0000, 0x0A7614], [1, 1], [10, 170], mat);

gr.graphics.moveTo(0,0);
var w:int = 1;
for (i=0; i<512; i+=w) {
var t:Number = ba.readFloat();
var n:Number = (t * 500);
gr.graphics.drawRect(i, 0, w, -n);
}
}


note that i did make this code...i just tweaked it
for it to work, you must change the address in the quotes in the first line to a website link to a song, OR the name of a music file placed in the same folder as the present flash file (and if i didn't mention it before, you have to save your flash file somewherefirst after you copy the code into it)...
you could hit play now and adore the prettiness ...and then help me with my problem
now that you are on the same track as me, what i want to do is add another sprite on top of the present one...but each time i do it, it compiles it without any errors, but while playing it , it doesn't show the sprites...

Any help will be greatly appreciated

Thanks a lot
- jpx
  • 16 Replies
jpx111
offline
jpx111
264 posts
Nomad

Ah...I get it now...thank you Dank.

Showing 16-16 of 16