加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

Flex 中鼠标进出框体的事件

发布时间:2020-12-15 01:41:48 所属栏目:百科 来源:网络整理
导读:利用Rectangle的contains或者containsPoint方法,得知鼠标 是否在Rectangle所表示的矩形范围内: ? ? ? //rollover指示ROLL_OVER事件,ROLL_OUT事件,rect用于检测的Rectangle,overPoint用于检测MOUSE_MOVE事件 var rollover : Boolean = false; var rect :

利用Rectangle的contains或者containsPoint方法,得知鼠标 是否在Rectangle所表示的矩形范围内:

?

?

?

//rollover指示ROLL_OVER事件,ROLL_OUT事件,rect用于检测的Rectangle,overPoint用于检测MOUSE_MOVE事件
var rollover : Boolean = false;
var rect : Rectangle = new Rectangle(0,200,300);
var overPoint : Point;???????
addEventListener(Event.ENTER_FRAME,enterFrameHandler);

?????????????? private function enterFrameHandler(event : Event) : void {
??????????????????????? var mousePoint : Point = new Point(stage.mouseX,stage.mouseY);
??????????????????????? if(rect.containsPoint(mousePoint)) {
??????????????????????? //鼠标进入rect范围
??????????????????????????????? if(!rollover){
??????????????????????????????????????? //鼠标首次进入rect
??????????????????????????????????????? rollover = true;
??????????????????????????????????????? overPoint = mousePoint;
??????????????????????????????????????? trace("ROLL_OVER");
??????????????????????????????? }else{
??????????????????????????????????????? //鼠标在rect内移动
??????????????????????????????????????? if(overPoint && Point.distance(overPoint,mousePoint) != 0){
??????????????????????????????????????????????? overPoint = mousePoint;
??????????????????????????????????????????????? trace("MOUSE_MOVE");
??????????????????????????????????????? }
??????????????????????????????? }
??????????????????????? }else{
???????????????????????? //鼠标移出rect范围
??????????????????????????????? if(rollover){
??????????????????????????????? //鼠标首次移出rect
??????????????????????????????????????? rollover = false;
??????????????????????????????????????? trace("ROLL_OUT");
??????????????????????????????? }
??????????????????????? }
??????????????? }

?


本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/wkyb608/archive/2010/12/03/6051866.aspx

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读