Adobe Flash。鼠标悬停动画无限循环

时间:2014-01-03 14:05:39

标签: actionscript-3 flash animation button adobe

我在为网站制作按钮时遇到了一些问题。我创建了一个按钮和一个动画,然后将该动画作为.swf导入到按钮文件中。我使用了以下代码(btn是按钮,mc是影片剪辑):

btn.addEventListener(MouseEvent.MOUSE_OVER,btnF);
function btnF(e:MouseEvent):void
{
    mc.play();
}

可以想象,当鼠标悬停在按钮上时,动画会播放,但它不会停止...任何解决方案?

详细信息:使用Actionscript 3.0
是的,我在最后用 stop()代码创建了影片剪辑...所以我不明白它为什么循环。

3 个答案:

答案 0 :(得分:0)

这样做可能更简单:创建一个按钮,在默认状态下有按钮的图形。在over状态下使用带动画的动画片段。这应该没有任何代码

答案 1 :(得分:0)

问题是如果鼠标悬停在“btn”显示对象上,MOUSE_OVER事件将始终触发。所以stop()代码最后工作,但是播放会覆盖该命令。

这是一个可能的解决方案:

btn.addEventListener(MouseEvent.MOUSE_OVER, btnF);
function btnF(e:MouseEvent):void{
{
     if(mc.currentFrame == 1)
     {
          mc.play();
     }
}

答案 2 :(得分:-1)

//i called the instance of the button : buthead and the instance of the movie clip : head_mc
//on the first frame of the movie clip, i've put a stop function

buthead.addEventListener(MouseEvent.MOUSE_OVER, function(event:MouseEvent):void {
    head_mc.play();
});