# AS3 Spectrum analyser - just one last question plz

**URL:** <https://forum.kirupa.com/t/as3-spectrum-analyser-just-one-last-question-plz/259113>\
**Category:** flash\
**Created:** [May 1, 2008, 7:32am UTC](https://forum.kirupa.com/t/as3-spectrum-analyser-just-one-last-question-plz/259113 "2008-05-01T07:32:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![humbucker](https://avatars.discourse-cdn.com/v4/letter/h/278dde/32.png) [@humbucker](https://forum.kirupa.com/u/humbucker)\
**Post date:** [May 1, 2008, 7:32am UTC](https://forum.kirupa.com/t/as3-spectrum-analyser-just-one-last-question-plz/259113/1 "2008-05-01T07:32:22Z")

</div>

Hello everyone,

I’m coming to this forum as a last chance to accomplish a spectrum analyser script i’ve modified so far.  
I’ve got one and only problem with it, i can’t get the bars backgrounds to be transparent (in fact I want to use this eq over an image in a project and dont want the bars to leave a color on the image used)  
I’ve uploaded a file for you to use and help if you will, just put a song renammed ‘son.mp3’ in the folder to test.  
You will see that the white bars leave black traces Id’like to remove.

A big thank you to you people who will help.  
have a nice day !

Btw, here is the code :

> 

package classes {  
import flash.display._;  
import flash.events._;  
import flash.geom.Matrix;  
import flash.net.URLRequest;  
import flash.media.Sound;  
import flash.media.SoundChannel;  
import flash.media.SoundTransform;  
import flash.utils.ByteArray;  
import flash.media.SoundMixer;  
import flash.geom.Rectangle;  
import flash.geom.Point;  
import flash.geom.ColorTransform;  
import flash.geom.Matrix;  
import flash.errors.EOFError;  
import flash.utils.Timer;

```
public class MainCoreX extends MovieClip {

```

public var outputBitmap:BitmapData  
public var myBytes:ByteArray;  
public var myColorTransform:ColorTransform;  
public var screenSprite:Sprite;  
public var myPoint:Point;  
public var myRectangle:Rectangle;  
public var nWidth:Number;  
public var globalIntro:intro = new intro();

```
public function MainCoreX() {
    init();
}

public function init():void {

```

initStage();  
startIntro();  
MainTest();  
}

```
private function initStage():void {
    stage.frameRate = 30;
    stage.showDefaultContextMenu = false;
    stage.scaleMode = StageScaleMode.NO_SCALE;
    stage.align = StageAlign.TOP_LEFT;
} 

```

public function startIntro():void {  
addChild(globalIntro);  
}

public function MainTest()  
{  
var mySound:Sound = new Sound();  
mySound.load ( new URLRequest (“son.mp3”) );  
mySound.play();  
BasicSpectrum ( 20,20,200 );  
}

public function BasicSpectrum ( pWidth:Number, pHeight:Number, pAmplitude:Number )  
{  
nWidth = pWidth;  
outputBitmap = new BitmapData ( pWidth, pHeight, true, 0x00FFFFF);  
myRectangle = new Rectangle (0, 0, 2, 0);  
myPoint = new Point (0, 0);  
screenSprite = new Sprite();  
screenSprite.addChild ( new Bitmap ( outputBitmap ) );  
globalIntro.spectre\_box.addChild ( screenSprite );  
myColorTransform = new ColorTransform (0xffffff, 0xffffff, 0xffffff);  
myBytes = new ByteArray();  
addEventListener (Event.ENTER\_FRAME, drawEqualizer);  
}

public function drawEqualizer (pEvt:Event):void  
{  
// computeSpectrum() to get a byteArray  
SoundMixer.computeSpectrum ( myBytes, true );  
var i:Number = 64;  
outputBitmap.colorTransform ( outputBitmap.rect, myColorTransform );

try {  
while ( --i \> -1 ) {  
// move the pointer so that it jump some bytes  
myBytes.position = i \* 16;  
// get amplitude value  
var offset:int = myBytes.readFloat()\*-25;  
// move the strike position  
myRectangle.x = (4 \* i);  
if ( offset \>= 0 ) {  
myRectangle.y = 20-offset;  
myRectangle.height = offset;  
// draw a strike with fillRect()  
outputBitmap.floodFill ( 0, 0, 0x00FFFFFF );  
} else {  
myRectangle.y = 0;  
myRectangle.height = -offset;  
outputBitmap.fillRect ( myRectangle, 0xFFFFFFFF )  
};  
}  
} catch (err:EOFError) {  
trace(“you’ve gone too far”)  
}  
}  
}  
}
