麦克风
package{ import flash.display.Sprite; import flash.events.ActivityEvent; import flash.events.Event; import flash.media.Microphone; public class Main extends Sprite { private var mic:Microphone; public function Main() { init(); } private function init():void { mic = Microphone.getMicrophone();//获取麦克风实例的方法 mic.setLoopBack();//启动麦克风 mic.setSilenceLevel(70,2000); this.addEventListener(Event.ENTER_FRAME,onEnterframeHandler); mic.addEventListener(ActivityEvent.ACTIVITY,onActivityhandler); } protected function onActivityhandler(event:ActivityEvent):void { if(event.activating == true) { trace("激活"+mic.activityLevel); }else { trace("停止"+ mic.activityLevel); } } protected function onEnterframeHandler(event:Event):void { //trace(mic.activityLevel); } }}
鼠标屏蔽右键
package{ import flash.display.Sprite; import flash.events.ContextMenuEvent; import flash.net.URLRequest; import flash.net.navigateToURL; import flash.ui.ContextMenu; import flash.ui.ContextMenuItem; public class Main extends Sprite { private var myMenu:ContextMenu; private var myItem:ContextMenuItem; private var myItem1:ContextMenuItem; public function Main() { myMenu = new ContextMenu();// myItem = new ContextMenuItem("SinSoul");// myItem1 = new ContextMenuItem("王二小");// myMenu.customItems.push(myItem);// myMenu.customItems.push(myItem1);// myMenu.hideBuiltInItems(); this.contextMenu = myMenu;// myItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,onMyItemCkickHandler);// this.contextMenu.hideBuiltInItems(); } protected function onMyItemCkickHandler(event:ContextMenuEvent):void { navigateToURL(new URLRequest("")); } }}
摄像头
package{ import flash.display.Bitmap; import flash.display.BitmapData; import flash.display.Sprite; import flash.events.ActivityEvent; import flash.events.Event; import flash.geom.Matrix; import flash.media.Camera; import flash.media.Video; public class Main extends Sprite { private var cam:Camera = Camera.getCamera(); private var vid:Video; private var bt:Bitmap = new Bitmap(); private var btd:BitmapData; public function Main() { if(stage == null) { init(null); }else { addEventListener(Event.ADDED_TO_STAGE,init); } } private function init(e:Event):void { removeEventListener(Event.ADDED_TO_STAGE,init); vid = new Video(400,400); btd = new BitmapData(400,400,false) bt.bitmapData = btd; this.addChild(bt); addEventListener(Event.ENTER_FRAME,onEnterFrameHandler); cam.setMode(400,400,15); vid.attachCamera(cam); cam.setMotionLevel(60,2000); cam.addEventListener(ActivityEvent.ACTIVITY,onActivityhandler); } protected function onActivityhandler(event:ActivityEvent):void { switch (event.activating) { case true: trace("动了"+cam.activityLevel); break; case false: trace("停止"+ cam.activityLevel) break; } } protected function onEnterFrameHandler(event:Event):void { btd.draw(vid,new Matrix(-1,0,0,1,400,0)); } }}