最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
检测鼠标离开Movie的动作
时间:2022-07-02 17:09:52 编辑:袖梨 来源:一聚教程网
在以前的AS版本中,你无法做到检测鼠标是否还在Flash Movie上。因此影片不能检测到用户是否在关注着当前的Movie。另外一个问题是,如果使用了自定义的鼠标样式,在鼠标移出Movie后,自定义的鼠标还是继续停留在影片上,而不能正确的显示鼠标当前的位置。
现在,AS3允许你通过监听stage的mouseLeave行为来捕获鼠标移出Movie的动作。mouseLeave行为在鼠标移出Movie的时候执行。但是现在并没有mouseEnter事件,不过你可以通过使用mouseMove来设置。
下面的例子中使用了一个方框来作为自定义的鼠标:
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.ui.Mouse;
public class Test extends Sprite {
private var cursor:Sprite = new Sprite();
public function Test() {
cursor.graphics.beginFill(0xFF);
cursor.graphics.drawRect(0, 0, 25, 25);
addChild(cursor);
stage.addEventListener(Event.MOUSE_LEAVE, cursorHide);
stage.addEventListener(MouseEvent.MOUSE_MOVE, cursorFollow);
Mouse.hide();
}
public function cursorHide(evt:Event):void {
cursor.visible = false;
}
public function cursorFollow(evt:MouseEvent):void {
if (!cursor.visible) cursor.visible = true;
cursor.x = stage.mouseX;
cursor.y = stage.mouseY;
evt.updateAfterEvent();
}
}
}
当鼠标离开Movie的时候,鼠标指针将被隐藏。当鼠标再次移动到Movie上的时候,mouseMove会被执行,然后显示鼠标。
相关文章
- 碧蓝航线的里雅斯特期待的便当时间皮肤有什么 04-30
- 明日之后踏浪逐星服装展示攻略 04-30
- 深空之眼幽月塞勒涅刻印搭配核心思路 04-30
- 明日之后红杉茶会护卫队首领BOSS有哪些 04-30
- CF手游段位奖励汇总攻略 04-30
- 无期迷途5-13怎么走攻略 04-30