2016-10-13 00:16:48 点击量:9 标签: 收藏本文
[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);
- }
- }
- }
- }
- }
我们是一家提供综合软件外包与弱电工程服务的技术公司。
业务涵盖定制软件、管理系统、网站、小程序、APP、系统集成、网络布线、监控安防、门禁、机房建设及长期技术维护。
公司地址:湖北省宜昌市伍家岗区东站二路6号三峡(宜昌)大数据产业园海洋馆二楼A203室