I have an 8 frame MC named symbol and I’m trying to get it to visualize when a song is playing. So I got this code and I’m new to AS3, but I get the basic gist of what’s happening. But how I do I get it to play my movie clip? Do I have to drag in onto the stage or what?
var requested:URLRequest = new URLRequest("http://av.adobe.com/podcast/csbu_dev_podcast_epi_2.mp3");
var s:Sound = new Sound();
s.addEventListener(Event.COMPLETE, completeHandler);
s.load(requested);
var song:SoundChannel=new SoundChannel();
s.addEventListener(Event.SOUND_COMPLETE, soundCompleteHandler);
var ba:ByteArray = new ByteArray();
var gr:Sprite = new Sprite();
gr.x = 20;
gr.y = 200;
addChild(gr);
var time:Timer = new Timer(50);
time.addEventListener(TimerEvent.TIMER, timerHandler);
time.start();
function completeHandler(event:Event):void {
song=event.target.play();
}
function soundCompleteHandler(event:Event):void {
time.stop();
}
var numOfFrames:int=52;
function timerHandler(event:TimerEvent):void {
SoundMixer.computeSpectrum(ba, false);
var i:int;
var w:uint = 15;
var p:int=0
for (i=0; i<512; i+=w) {
var t:Number = ba.readFloat();
p+=t
}
symbol.gotoAndStop(Math.abs(Math.ceil((p)*8)/256))
}
This is my fla: