《Flash Lite 2.x ActionScript 语言参考》 |
|
|
|
| ActionScript 语言元素 > 全局函数 > onClipEvent 处理函数 | |||
onClipEvent(movieEvent:Object) { // your statements here }
触发为特定影片剪辑实例定义的动作。
movieEvent:Object ― movieEvent 是一个称为事件的触发器。当事件发生时,执行该事件后面大括号 ({}) 中的语句。可以为 movieEvent 参数指定下面的任一值:
load 影片剪辑一旦被实例化并出现在时间轴中,即启动此动作。unload 在从时间轴中删除影片剪辑之后,此动作即在第 1 帧中启动。在将任何动作附加到受影响的帧之前处理与 Unload 影片剪辑事件关联的动作。enterFrame 以影片剪辑的帧速率连续触发该动作。在将任何帧动作附加到受影响的帧之前处理与 enterFrame 剪辑事件关联的动作。mouseMove 每次移动鼠标时启动此动作。可以使用 _xmouse 和 _ymouse 来确定当前鼠标位置。System.capabilities.hasMouse 为 true 时,Flash Lite 中才支持此事件。mouseDown 当按下鼠标左键时启动此动作。System.capabilities.hasMouse 为 true 或 System.capabilities.hasStylus 为 true 时,Flash Lite 中才支持此事件。mouseUp 当释放鼠标左键时启动此动作。System.capabilities.hasMouse 为 true 或 System.capabilities.hasStylus 为 true 时,Flash Lite 中才支持此事件。keyDown 当按下某个键时启动此动作。使用 Key.getCode() 检索有关最后按下的键的信息。keyUp 当释放某个键时启动此动作。可以使用 Key.getCode() 方法来检索有关最后按下的键的信息。data 在 loadVariables() 或 loadMovie() 动作中接收到数据时启动该动作。当与 loadVariables() 动作一起指定时,data 事件只在加载最后一个变量时发生一次。当与 loadMovie() 动作一起指定时,则在检索数据的每一部分时,data 事件都重复发生。下面的示例将 onClipEvent() 与 keyDown 影片事件一起使用,旨在附加到影片剪辑或按钮。keyDown 影片事件通常与 Key 对象的一个或多个方法和属性一起使用。下面的脚本使用 Key.getCode() 找出用户按下了哪个键;如果按下的键与 Key.RIGHT 属性相匹配,则播放头会转到下一帧;如果按下的键与 Key.LEFT 属性相匹配,则播放头会转到上一帧。
onClipEvent (keyDown) {
if (Key.getCode() == Key.RIGHT) {
this._parent.nextFrame();
} else if (Key.getCode() == Key.LEFT) {
this._parent.prevFrame();
}
}
下面的示例将 onClipEvent() 与 load 和 mouseMove 影片事件一起使用。xmouse 和 ymouse 属性在鼠标每次移动时跟踪鼠标的位置,鼠标位置显示在运行时创建的文本字段中。
onClipEvent (load) {
this.createTextField("coords_txt", this.getNextHighestDepth(), 0, 0, 100, 22);
coords_txt.autoSize = true;
coords_txt.selectable = false;
}
onClipEvent (mouseMove) {
coords_txt.text = "X:"+_root._xmouse+",Y:"+_root._ymouse;
}
Key, _xmouse(MovieClip._xmouse 属性), _ymouse(MovieClip._ymouse 属性), on 处理函数
|
|
|
|