Media Servers : Microphone : Development Flash / Flex / ActionScript examples


Flash / Flex / ActionScript examples » Development » Microphone »

 

Media Servers


 
package
{
    import flash.display.Sprite;
    import flash.events.ActivityEvent;
    import flash.events.Event;
    import flash.events.StatusEvent;
    import flash.media.Microphone;
    public class Main extends Sprite
    {
        public var mic:Microphone = Microphone.getMicrophone();
        public var level:Sprite = new Sprite();

        public function Main()
        {
            mic.setLoopBack(true);
            mic.addEventListener(ActivityEvent.ACTIVITY, activity);
            mic.addEventListener(StatusEvent.STATUS, status);
            mic.addEventListener(Event.ACTIVATE, active);
            addEventListener(Event.ENTER_FRAME, showMicLevel);
            addChild(level);
            level.y = 200;
            level.x = 100;
        }

        private function active(event:Event):void
        {

            trace("active");
        }

        private function status(event:StatusEvent):void
        {
            trace("status");
        }

        private function activity(event:ActivityEvent):void
        {
            trace("activity");
        }

        private function showMicLevel(event:Event):void
        {
            trace(mic.gain
                    " " + mic.activityLevel
                    " " + mic.silenceLevel
                    " " + mic.index
                    " " + mic.rate);
            level.graphics.beginFill(0xccccff1);
            level.graphics.drawRect(00(mic.activityLevel * 3)100);
            level.graphics.endFill();
        }
    }
}

        



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


Flash / Flex / ActionScript examples

 Navioo Development
» Microphone