topical media & game development
lib-flex-animation-code-05-Clapper.ax
lib-flex-animation-code-05-Clapper.ax
(swf
)
[ flash
]
flex
package {
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.ActivityEvent;
import flash.media.Microphone;
public class @ax-lib-flex-animation-code-05-Clapper extends Sprite
{
private var _mic:Microphone;
private var _on:Boolean = false;
public function @ax-lib-flex-animation-code-05-Clapper()
{
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
update();
_mic = Microphone.getMicrophone();
_mic.setSilenceLevel(25, 500);
_mic.setLoopBack();
_mic.addEventListener(ActivityEvent.ACTIVITY, onActivity);
}
private function onActivity(event:ActivityEvent):void
{
if(event.activating)
{
_on = !_on;
update();
}
}
private function update():void
{
graphics.clear();
if(_on)
{
graphics.beginFill(0xffffff);
}
else
{
graphics.beginFill(0);
}
graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
}
}
}
(C) Æliens
18/6/2009
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.