MOUSE_OVER 时播放 Movieclip 的一帧

Play a frame of a Movieclip when MOUSE_OVER

我有一张不同国家的地图。当我将鼠标悬停在其中一个国家/地区时,我希望它播放电影片段的特定帧。我为每个国家/地区制作了一个影片剪辑,其中有 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);
}

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

您当前的代码将在主时间线上执行 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);
}