How to convert a drawing API to a Bitmap at run time?

Hi All :)!

Over the weekend i put together an MP3 player in Flex and just managed to figure out the SoundSpectrum.

It is working as expected.

I am facing problems when it comes to using a bitmap.

Right now, my “Analyser” class pulls the data from SoundMixer.computerSpectrum.

I then use that data with the drawing API to create a simple analyser. You know, just spikes.

Here is the code for that part:

private function update(e:TimerEvent): void
{
            SoundMixer.computeSpectrum(ba, true);
            
            var n:Number = 0;
            var g:Graphics = this.graphics;
            g.clear();
            g.beginFill(0xffffff, 1);
            g.lineStyle(0, 0x000000, 0, true);
            g.moveTo(0,0);
            
            
            for (var i:int = 0; i < 256; i++)
            {
                n = ba.readFloat()*-10;
                g.lineTo((i*2), (i*n));
            }
            
            g.endFill();
}

Well what i want to be able to do, is use bitmapData and apply some filter effects to my spikes. Having created a bitmap instance, my update frame now looks like this:

private function update(e:TimerEvent): void
{
            SoundMixer.computeSpectrum(ba, true);
            
            var n:Number = 0;
            var g:Graphics = this.graphics;
            g.clear();
            g.beginFill(0xffffff, 1);
            g.lineStyle(0, 0x000000, 0, true);
            g.moveTo(0,0);
            
            
            for (var i:int = 0; i < 256; i++)
            {
                n = ba.readFloat()*-10;
                g.lineTo((i*2), (i*n));
            }
            
            g.endFill();
            
            bitmapData.draw(this);
            bitmapData.scroll(0, -2);
}

Ok using common sense here, I am telling flash to take a snapshot of the Analyser and draw it to the bitmapData.

However, i cant seem to get this working. I am not using the dispose() method to clear the bitmap so id expect to see a mess of points (similar to if i removed the g.clear()) but nothing happens.

Does anyone know why?

Thanks :D!