【问题标题】:How to make a flash 3.0 script play once on MOUSE_OVER (or ROLL_OVER) then once per every such event?如何让 Flash 3.0 脚本在 MOUSE_OVER(或 ROLL_OVER)上播放一次,然后在每个此类事件中播放一次?
【发布时间】:2014-01-16 10:17:25
【问题描述】:

我是一个新手,想为我的网站做一些按钮。我有这个用于 flash 3.0 的动作脚本:

this.home.addEventListener(MouseEvent.ROLL_OVER, function(e:MouseEvent): void{

    play();

});

stop();

它可以工作,并且闪光灯连续播放,但我想让它在鼠标悬停在按钮上时只播放一次。 结尾帧中的stop(); 不起作用,它会在鼠标悬停时停止闪光灯第二次播放。试过ROLL_OVERMOUSE_OVER,没有运气。 一定有一个简单的技巧,但还没有达到。

【问题讨论】:

标签: actionscript-3 flash


【解决方案1】:

您需要在事件侦听器第一次触发后移除它。所以:

this.home.addEventListener(MouseEvent.ROLL_OVER, function(e:MouseEvent): void{

    this.home.removeEventListener(MouseEvent.ROLL_OVER, arguments.callee);
    play();

});

【讨论】:

  • 谢谢你,Scott,你的建议帮助我完成了它。
【解决方案2】:

看来这段代码有效,我的运气!

stop();
home.addEventListener(MouseEvent.ROLL_OVER, manageMouseOver, false, 0, true);

 function manageMouseOut(event:MouseEvent):void{
  home.removeEventListener(MouseEvent.ROLL_OVER, manageMouseOver);
  home.addEventListener(MouseEvent.ROLL_OVER, manageMouseOver, false, 0, true);
  play();
}

function manageMouseOver(event:MouseEvent):void{
  home.removeEventListener(MouseEvent.ROLL_OVER, manageMouseOut);
  home.addEventListener(MouseEvent.ROLL_OVER, manageMouseOut, false, 0, true);
  stop();
}

它可以满足我的需求,鼠标悬停播放一次。 呸!

【讨论】:

    【解决方案3】:

    经过一些格式化后,我得到了这个:

    stop()
    
    home.addEventListener(MouseEvent.MOUSE_OVER, manageMouseOver, false, 0, true);
    function manageMouseOut(event:MouseEvent):void{
      play();
    }
    function manageMouseOver(event:MouseEvent):void{
    home.addEventListener(MouseEvent.MOUSE_OVER, manageMouseOut, false, 0, true);
      stop();
    }
    

    效果很好。 有 2 层,62 帧(第 1 层)。 'home' 是按钮名称。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-06-24
      • 1970-01-01
      • 1970-01-01
      • 2013-05-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多