Use Microphone : Microphone « Development « Flash / Flex / ActionScript

Home
Flash / Flex / ActionScript
1.Animation
2.Array
3.Class
4.Data Type
5.Development
6.Function
7.Graphics
8.Language
9.Network
10.Regular Expressions
11.Statement
12.String
13.TextField
14.XML
Flash / Flex / ActionScript » Development » Microphone 
Use Microphone
 
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;

        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);
            level = new Sprite();
            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();
        }
    }
}

        
Related examples in the same category
1.Media Servers
2.Introducing the Microphone
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.