我以为这是一件非常基本的事情,但是我已经将自己置身于一个角落。我只是希望每次将鼠标悬停在按钮类型元素上时都播放声音,而不管按钮的位置,生根,父对象,名称,实例名称等如何。
声音文件在类/链接“滚动”(声音翻转)中的库中,我使用以下方法播放所有其他声音:
MovieClip(root).audio_channel_c = MovieClip(root).snd8.play(0,1);
在我看来,我正在寻找以下方面的东西:
public button.eventlistener(MouseEvent.ROLL_OVER, function(){
MovieClip(root).audio_channel_c = MovieClip(root).snd10.play(0,1);
});
我在AS3工作
最佳答案
经过更多搜索之后,我发现了一种相当粗糙的方法。侦听器在每次像素移动时拾取光标下方的内容。如果光标下方的像素是对象类的SimpleButton,它将确定鼠标是否仍在它已经输入的按钮上移动。如果是新鲜输入,它会跟踪。
每次光标进入一个按钮时,结果都是跟踪,但滚动到该按钮时不会。它也适用于整个阶段中每个按钮的每个实例。
import flash.events.MouseEvent;
import flash.display.SimpleButton;
import flash.utils.getQualifiedClassName;
function getClass(obj:Object):Class {
return Class(getDefinitionByName(getQualifiedClassName(obj)));
}
var last_button_to_mouse = "";
stage.addEventListener(MouseEvent.MOUSE_MOVE, handle_custom_event, true);
function handle_custom_event(e:Event):void
{
if(getQualifiedClassName(e.target)!="flash.display::SimpleButton"){
last_button_to_mouse = ""
}
if(getQualifiedClassName(e.target)=="flash.display::SimpleButton" && (e.target.name != last_button_to_mouse)){
last_button_to_mouse = e.target.name;
trace("Place your script here for when the mouse enters any button on the stage");
}
}
关于actionscript-3 - 翻转电影中所有按钮时播放声音,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30140309/