Actionscript 3 动作脚本3.0-MouseeEvent侦听器+功能问题
我正在做一个在舞台上有多个可点击对象的项目 但是,当我创建以下函数时,我得到了最后定义的eventlistenerActionscript 3 动作脚本3.0-MouseeEvent侦听器+功能问题,actionscript-3,flash,actionscript,mouseevent,Actionscript 3,Flash,Actionscript,Mouseevent,我正在做一个在舞台上有多个可点击对象的项目 但是,当我创建以下函数时,我得到了最后定义的eventlistener // Event listeners antwoordBox1.addEventListener(MouseEvent.CLICK, antwoordboxclick); antwoordBox2.addEventListener(MouseEvent.CLICK, antwoordboxclick); function antwoordboxclick(event:MouseE
// Event listeners
antwoordBox1.addEventListener(MouseEvent.CLICK, antwoordboxclick);
antwoordBox2.addEventListener(MouseEvent.CLICK, antwoordboxclick);
function antwoordboxclick(event:MouseEvent):void {
trace (event.currentTarget.name); // traces 'antwoordBox2' , whether I click any of the buttons.
if (event.currentTarget.name == 'antwoordBox1') {
trace('antwoordBox1 selected');
}
if (event.currentTarget.name == 'antwoordBox2') {
trace('antwoordBox2 selected');
}
currentQuestion++; // function to handle after above
trekNieuweVraag(); // another function to handle after above
}
// end of my code
不管我怎么做,我都不会把它修好。当我使用event.target时,我会在antwoordBox2或antwoordBox1中获得子movieclip名称
希望有人能帮助我
禁用鼠标与antwoordBox的子对象的交互:
antwoordBox1.mouseChildren = false;
antwoordBox2.mouseChildren = false;
注册事件侦听器:
addEventListener(MouseEvent.CLICK, antwoordboxclick);
在事件处理程序内部:
if (event.target == antwoordBox1)
trace('antwoordBox1 selected');
else if (event.target == antwoordBox2)
trace('antwoordBox2 selected');
尝试验证您的antwoordBox2是否在antwoordBox1上。subdan的解决方案在@akmozo有效,非常感谢您与我一起思考。非常感谢您帮助我@subdan。你就是炸弹我在寻找老鼠宝宝的解决方案。谢谢