Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 动作脚本3.0-MouseeEvent侦听器+功能问题_Actionscript 3_Flash_Actionscript_Mouseevent - Fatal编程技术网

Actionscript 3 动作脚本3.0-MouseeEvent侦听器+功能问题

Actionscript 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

我正在做一个在舞台上有多个可点击对象的项目

但是,当我创建以下函数时,我得到了最后定义的eventlistener

// 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。你就是炸弹我在寻找老鼠宝宝的解决方案。谢谢