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

フォーカスが外れた際のステージのマウス座標

flash領域外クリックやブラウザからフォーカスが外れたときの
stage.mouseX の値を見るテスト
Get Adobe Flash player
by cda244 25 Sep 2009
/**
 * Copyright cda244 ( http://wonderfl.net/user/cda244 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/tmsP
 */

/*
	flash領域外クリックやブラウザからフォーカスが外れたときの
	stage.mouseX の値を見るテスト
*/

package
{
	import flash.display.MovieClip;
	import flash.text.TextField;
	import flash.events.*;
	
	[SWF(width="400", height="300", backgroundColor="0xFFFFFF", frameRate="30")]
	
	public class Main extends MovieClip
	{
		
		private var _txt1, _txt2:TextField;
		
		public function Main():void
		{
			_txt1 = new TextField();
			_txt2 = new TextField();
			_txt1.width = _txt2.width = 200;
			_txt1.height = _txt2.height = 200;
			_txt2.x = 200;
			addChild(_txt1);
			addChild(_txt2);
			
			addEventListener(Event.ENTER_FRAME, en);
			stage.addEventListener(MouseEvent.MOUSE_MOVE, mv);
		}
		
		
		private function en(evt:Event):void
		{
			_txt1.text = "\nflash領域外でも反応する?\nENTER_FRAME\n\n mouseX "+stage.mouseX+"\n mouseY "+stage.mouseY;
		}
		
		private function mv(mEvt:MouseEvent):void
		{
			_txt2.text = "\nflash領域外でも反応する?\nMOUSE_MOVE\n\n mouseX"+stage.mouseX+"\n mouseY"+stage.mouseY;
		}
		
		
		
	}
	
}