【问题标题】:Play a frame of a Movieclip when MOUSE_OVER鼠标悬停时播放影片剪辑的一帧
【发布时间】:2015-05-20 22:41:56
【问题描述】:

我有一张不同国家的地图。当我将鼠标悬停在其中一个国家上时,我希望它播放电影剪辑的某个帧。我为每个国家制作了一个电影剪辑,它有 2 帧。 1. 框架只是地图上显示的国家的图片。第 2 帧是上面有名字的国家。第二帧包含一个 stop();这是我的代码:

rømskog.addEventListener(MouseEvent.MOUSE_OVER,mover);
halden.addEventListener(MouseEvent.MOUSE_OVER,mover);
askim.addEventListener(MouseEvent.MOUSE_OVER,mover);
rømskog.addEventListener(MouseEvent.MOUSE_OUT,outer);
halden.addEventListener(MouseEvent.MOUSE_OUT,outer);
askim.addEventListener(MouseEvent.MOUSE_OUT,outer);

function mover(e:MouseEvent):void {
   gotoAndPlay(2);
}

function outer(e:MouseEvent):void {
   gotoAndPlay(1);
}

我知道这段代码不正确,但我正在努力解决问题。我的movieclip 也自动启动,因为从一开始就可以看到国家名称。如果有人能以最简单的方式学习我,我会非常高兴!

【问题讨论】:

  • 主时间线,正确。你想要电影剪辑吗?如何以及采用什么文件格式?

标签: actionscript-3 flash mouseevent mouseover


【解决方案1】:

您当前的代码将在主时间线上执行gotoAndPlay。您需要将国家/地区影片剪辑时间线改为相应的帧。

您需要做的就是像这样修改您的两个函数:

function mover(e:MouseEvent):void {
   //e.currentTarget is a reference to the object that was clicked.  To avoid a compiler warning, we tell flash it's a movie clip.
   MovieClip(e.currentTarget).gotoAndStop(2); //if you don't want to actually play the timeline, use gotoAndStop
}

function outer(e:MouseEvent):void {
   //since this code is in the main timeline, doing gotoAndPlay will apply to it, not the object clicked

   //so like above, we tell the current target of the event to gotoAndPlay
   MovieClip(e.currentTarget).gotoAndStop(1);
}

【讨论】:

  • 感谢您的帮助!我不确定 MOUSE_OVER 和 MOUSE_OUT 是否在做我想做的事。我希望隐藏第 2 帧,直到我选择将鼠标放在它上面。现在它是可见的,直到我把鼠标放在上面,如果我把鼠标移到上面它会闪烁
  • 您所在国家/地区的第一帧是否有stop();?你说的眨眼是什么意思?确保您的国家/地区有良好的鼠标悬停区域,如果需要,创建透明背景以帮助定义鼠标悬停区域。
  • 我设法修复它,所以我的程序按预期工作。非常感谢
猜你喜欢
  • 2017-05-06
  • 2011-07-23
  • 2013-04-04
  • 2010-10-02
  • 2012-05-26
  • 1970-01-01
  • 2015-09-16
  • 2023-04-05
  • 1970-01-01
相关资源
最近更新 更多