[AS3]AS3点击空白区域隐藏鼠标动作
[AS3]AS3点击空白区域隐藏鼠标动作
[AS3]AS3点击空白区域隐藏鼠标动作
- package
- {
- import flash.display.Sprite;
- import flash.events.Event;
- import flash.events.MouseEvent;
- /**
- * ...
- * @author BBB
- */
- public class Main extends Sprite
- {
- private var _bg:Sprite;
- private var _btn:Sprite;
- private var _popWindow:Sprite;
- 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
- _bg = new Sprite();
- _bg.graphics.beginFill(0xCCCCCC);
- _bg.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
- addChild(_bg);
- _btn = new Sprite();
- _btn.graphics.beginFill(0xFF0000);
- _btn.graphics.drawCircle(0, 0, 20);
- addChild(_btn);
- _btn.x = 100;
- _btn.y = 100;
- _popWindow = new Sprite();
- _popWindow.graphics.beginFill(0x111111);
- _popWindow.graphics.drawRoundRect(0, 0, 160, 120, 10, 10);
- _popWindow.x = (stage.stageWidth-_popWindow.width) * .5;
- _popWindow.y = (stage.stageHeight - _popWindow.height) * .5;
- _popWindow.addEventListener(MouseEvent.CLICK, onClick2);
- var child:Sprite = new Sprite();
- child.graphics.beginFill(0x00FF00);
- child.graphics.drawCircle(0, 0, 10);
- child.x = 50;
- child.y = 50;
- child.addEventListener(MouseEvent.CLICK, onClick3);
- _popWindow.addChild(child);
- stage.addEventListener(MouseEvent.CLICK, onClick);
- }
- private function onClick3(e:MouseEvent):void
- {
- trace("child");
- }
- private function onClick2(e:MouseEvent):void
- {
- trace("popWindow");
- e.stopPropagation();
- }
- private function onClick(e:MouseEvent):void
- {
- if (e.target == _btn) {
- addChild(_popWindow);
- }else {
- if (contains(_popWindow)) {
- removeChild(_popWindow);
- }
- }
- }
- }
- }
热门文章推荐
- [HLS]做自己的m3u8点播系统使用HTTP Live Streaming(HLS技术)
- [FMS]FMS流媒体服务器配置与使用相关的介绍
- [AS3]什么是M3U8,与HTML5的区别是什么
- AS2.0 让flash自适应全屏,并且不自动缩放
- [AS3]as3.0的sound类常用技巧整理
- [AS3]as3与ByteArray详解、ByteArray介绍、ByteArray用法
- 关于RTMP,RTMPT,RTMPS,RTMPE,RTMPTE协议的介绍
- [JS]分享浏览器弹出窗口不被拦截JS示例
请稍候...