In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

shout

このネタを何人の人が知っているか不安ですが、
Flashのマイクテストです。
Get Adobe Flash player
by bao_bao 24 May 2009
    Embed
/**
 * Copyright bao_bao ( http://wonderfl.net/user/bao_bao )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/eMZ1
 */

/*
このネタを何人の人が知っているか不安ですが、
Flashのマイクテストです。
*/
package 
{
	import flash.display.Loader;
	import flash.display.Sprite;
	import flash.events.ActivityEvent;
	import flash.events.Event;
	import flash.events.StatusEvent;
	import flash.media.Microphone;
	import flash.media.Microphone;
	import flash.net.URLRequest;
	import flash.system.LoaderContext;
	import flash.system.Security;
	import flash.geom.Matrix;
	import flash.display.Bitmap;
	import flash.display.LoaderInfo;
	/**
	 * ...
	 * @author Shunsuke Ohba
	 */
	public class Main extends Sprite 
	{
		private const BG_URL:String="http://wonderfl.reinit.info/dora/dora_bg.gif";
		private const TOOL_URL:String="http://wonderfl.reinit.info/dora/dora_tool.gif";
		private var _mic:Microphone;
		private var _bmpBg:Bitmap;
		private var _bmpTool:Bitmap;
		
		public function Main():void 
		{
			if (stage) init();
			else addEventListener(Event.ADDED_TO_STAGE, init);
		}
		
		private function init(e:Event = null):void 
		{
			removeEventListener(Event.ADDED_TO_STAGE, init);
			// entry point
			
			Security.loadPolicyFile("http://wonderfl.reinit.info/crossdomain.xml");
			_bmpBg = new Bitmap();
			addChild(_bmpBg);
			_bmpTool = new Bitmap();
			var loader:Loader = new Loader;
			loader.load(new URLRequest(BG_URL));
			loader.contentLoaderInfo.addEventListener(Event.COMPLETE, function(e:Event):void
			{
				_bmpBg.bitmapData = Bitmap(LoaderInfo(e.currentTarget).content).bitmapData;
				var __loader:Loader = new Loader;
				__loader.contentLoaderInfo.addEventListener(Event.COMPLETE, _onComplete);
				__loader.load(new URLRequest(TOOL_URL), new LoaderContext(true));
			});
		}
		
		private function _onComplete(e:Event):void 
		{
			_bmpTool.bitmapData = Bitmap(LoaderInfo(e.currentTarget).content).bitmapData;
			_mic = Microphone.getMicrophone();
			_mic.setLoopBack(true);
                        _mic.gain=20;
			_mic.addEventListener(ActivityEvent.ACTIVITY, _onActivity);
		}
		private function _onActivity(e:ActivityEvent):void 
		{
			addEventListener(Event.ENTER_FRAME, _onEnterFrame);
		}
		
		private function _onEnterFrame(e:Event):void 
		{
			if (_mic.activityLevel >= 100) {
			    //_mic.setLoopBack(false);
			    _mic.removeEventListener(ActivityEvent.ACTIVITY, _onActivity);
			    removeEventListener(Event.ENTER_FRAME, _onEnterFrame);
			    addChild(_bmpTool);
			}
		}
	}
}