Flash Player 10.1 test
/**
* Copyright mash ( http://wonderfl.net/user/mash )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/kyHk
*/
package {
import flash.display.Sprite;
import flash.events.SampleDataEvent;
import flash.media.Microphone;
import flash.text.TextField;
public class FlashTest extends Sprite {
private var tf :TextField;
private var counter :int = 0;
public function FlashTest() {
addTF();
var mic:Microphone = Microphone.getMicrophone();
if ( mic ) {
tf.appendText( mic.name + " found, data from mic will follow if FP10.1 enabled\n" );
mic.setLoopBack(true);
mic.rate = 44;
mic.addEventListener(SampleDataEvent.SAMPLE_DATA, micSampleDataHandler);
}
else {
tf.appendText( "no mic found.." );
}
}
private function micSampleDataHandler( e :SampleDataEvent ) :void {
tf.appendText(
"["+ counter++ +"]"
+ e.data.length
+ "\n" );
}
private function addTF() :void {
tf = new TextField;
tf.width = 465;
tf.height = 465;
tf.text = "start..\n";
addChild( tf );
}
}
}