Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/35.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 AS3 mouseChildren=false将事件侦听器添加到子级_Actionscript 3_Events_Mouseevent - Fatal编程技术网

Actionscript 3 AS3 mouseChildren=false将事件侦听器添加到子级

Actionscript 3 AS3 mouseChildren=false将事件侦听器添加到子级,actionscript-3,events,mouseevent,Actionscript 3,Events,Mouseevent,我在flash中有一个下拉菜单,有两个下拉按钮。在我使用的对象上添加以下事件侦听器: addEventListener(MouseEvent.MOUSE_OVER, expand); addEventListener(MouseEvent.MOUSE_OUT, contract); public function expand(evt:MouseEvent):void { if(!expanded) {

我在flash中有一个下拉菜单,有两个下拉按钮。在我使用的对象上添加以下事件侦听器:

addEventListener(MouseEvent.MOUSE_OVER, expand);
addEventListener(MouseEvent.MOUSE_OUT, contract);

public function expand(evt:MouseEvent):void
        {
            if(!expanded)
            {
                TweenMax.to(this.back, 0.15, {height:82, onComplete:function(){
                    music.alpha = 1;
                    music.y = 32;
                    quit.alpha = 1;
                    quit.y = 55;
                }});
                expanded = true;
            }
        }

    public function contract(evt:MouseEvent):void
    {
        if(expanded)
        {
            this.music.alpha = 0;
            this.music.y = 0 - this.height;
            this.quit.alpha = 0;
            this.quit.y = 0 - this.height;
            TweenMax.to(this.back, 0.15, {height:0});
            expanded = false;
        }
    }
为了使菜单正常工作,我需要添加此代码,这样子菜单就不会干扰这两个功能的触发

this.mouseChildren = false;
现在,我希望下拉列表上的两个按钮可以单击并触发不同的事件,但由于mouseChildren设置为false,因此它不会侦听事件。如何将事件分配给对象的子元素,而不让扩展、收缩功能被这两个子元素的交互中断

谢谢, 布伦南

你就不能说:

this.mouseChildren = true;
内部的onComplete功能为您的扩展之间

然后:

this.mouseChildren = false;
收缩吐温的onComplete函数的内部


这将仅在菜单展开时才在这些子项上启用鼠标。

这不起作用。一旦它设置为true,契约的事件监听器就会被触发。好的,当我将事件监听器更改为ROLL\u OVER and ROLL\u OUT时,它就工作了!谢谢