Hi everybody!
I’m really stuck in this issue… And I’d like to find out your help!
I found on Adobe site this code to create the waveform in realtime of what is captured by the microphone. And it works really great.
—WORKING CODE----
import flash.media.Microphone;
import flash.events.SampleDataEvent;
import flash.utils.ByteArray;
import flash.display.Graphics;
var nWidth:Number = stage.stageWidth;
var nCenter:Number = stage.stageHeight / 2;
var nScale:Number = 100;
var myGraphics:Graphics = graphics;
var my_mic:Microphone = Microphone.getMicrophone();
my_mic.rate = 10;
my_mic.gain = 50;
my_mic.addEventListener(SampleDataEvent.SAMPLE_DATA, drawSampleData);
function drawSampleData(eventObject:SampleDataEvent):void
{
var myData:ByteArray = eventObject.data;
myGraphics.clear();
myGraphics.lineStyle(0, 0x000000);
myGraphics.moveTo(0, nCenter);
var nPitch:Number = nWidth / myData.length;
while (myData.bytesAvailable > 0)
{
var nX:Number = myData.position * nPitch;
var nY:Number = myData.readFloat() * nScale + nCenter;
myGraphics.lineTo(nX, nY);
}
}
---- END OF WORKING CODE ----
The problem is that I’m not smart enough with the ByteArray and the Graphics libraries and I cannot figure out how to put this graphics (realtime generated) inside a movie clip. I need to put it in the movie clip to be able to move the graphics object OVER another mc or bitmap, while now is always in the back of the stage.
Could somebody helps?
Thanks in advance.
ZONG