I have some code that makes some crazy EQ’s when playing an mp3 file. Which isn’t the problem. I have to add a preloader to the code along with a mute/resume button. I’ve been trying for a few days to get it to work and have gotten no where. Anyone able to help. Need it for a Micro website for a very famous band, which I cannot name at this time.
Here’s the code:
package {
import flash.display.Shape;
import flash.display.Sprite;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.media.SoundMixer;
import flash.utils.ByteArray;
import flash.net.URLRequest;
import flash.events.*;
import flash.geom.*;
import flash.filters.*;
public class SpectrumManager extends Sprite{
private var _barArray:Array;
private var _barArray2:Array;
private var _lineArray:Array;
private var _lineArray2:Array;
private var _sound:Sound;
private var _sc:SoundChannel;
private var _ba:ByteArray;
private var _numBars:int;
public function SpectrumManager() {
_barArray = new Array();
_barArray2 = new Array();
_lineArray = new Array();
_lineArray2 = new Array();
_sound = new Sound();
_sc = new SoundChannel();
_ba = new ByteArray();
_numBars = 62;
stage.frameRate=30;
makeBars();
function makeBars():void {
for (var i:int = 0; i < _numBars; i++){
var bar:Shape = new Shape();
var dropShadow:DropShadowFilter = new DropShadowFilter(6, 45, 0x00FF00, 1, 10, 10, 2, 1);
bar.graphics.beginFill(0xFF0099);
bar.graphics.drawRect(-35,-75,1,40);
bar.graphics.endFill();
bar.filters = [dropShadow];
bar.y = bar.height + 140;
bar.x = 60 + i*4;
addChild(bar);
_barArray.push(bar);
var bar2:Shape = new Shape();
bar2.graphics.beginFill(0xFF0099);
bar2.graphics.drawRect(-35,55,1,40);
bar2.graphics.endFill();
bar2.alpha = 0.4;
bar2.filters = [dropShadow];
bar2.y = bar2.height + 140;
bar2.x = 62 + i*4;
addChild(bar2);
_barArray2.push(bar2);
var line1:Shape = new Shape();
line1.graphics.beginFill(0x66FFFF);
line1.graphics.drawRect(-35,-90,1,2);
line1.graphics.endFill();
line1.y = bar.height+105;
line1.x = 60 + i*4;
addChild(line1);
_lineArray.push(line1);
var line2:Shape = new Shape();
line2.graphics.beginFill(0x66FFFF);
line2.graphics.drawRect(50,75,1,2);
line2.graphics.endFill();
line2.alpha = 0.4;
line2.y = bar2.height+200;
line2.x = 62 + i*4;
addChild(line2);
_lineArray2.push(line2);
}
playMusic();
}
function playMusic():void {
_sound.load(new URLRequest("so_what.mp3"));
_sc = _sound.play(0, 25);
var enterFrameController:Sprite = new Sprite();
enterFrameController.addEventListener (Event.ENTER_FRAME, animateBars);
}
function animateBars():void {
SoundMixer.computeSpectrum(_ba, true, 2);
for (var i:int = 0; i < _numBars; i++){
_barArray*.scaleY = _ba.readFloat();
_barArray2*.scaleY = _ba.readFloat();
_lineArray*.scaleY = _ba.readFloat();
_lineArray2*.scaleY = _ba.readFloat();
}
}
}
}
}
Credit will be given to those who are able to help.
Thanks very much,
Steve