Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/6.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 Flex4列表项渲染器子项和事件_Actionscript 3_Apache Flex_Flex4 - Fatal编程技术网

Actionscript 3 Flex4列表项渲染器子项和事件

Actionscript 3 Flex4列表项渲染器子项和事件,actionscript-3,apache-flex,flex4,Actionscript 3,Apache Flex,Flex4,我有一个自定义的项目渲染器,我在列表中使用。项目渲染器中有一个复选框和一个颜色选择器。我已经为这两个项目创建了自己的自定义事件类,它们不会冒泡它们的事件 您也可以单击列表中的项,我有3个侦听器附加到列表,我不希望在单击列表的子项时触发列表项处理程序,我如何做到这一点 摘录如下: protected function updateList():void { var proxy:ApplicationDataProxy = ApplicationDataProxy(facade.

我有一个自定义的项目渲染器,我在列表中使用。项目渲染器中有一个复选框和一个颜色选择器。我已经为这两个项目创建了自己的自定义事件类,它们不会冒泡它们的事件

您也可以单击列表中的项,我有3个侦听器附加到列表,我不希望在单击列表的子项时触发列表项处理程序,我如何做到这一点

摘录如下:

     protected function updateList():void
  {
   var proxy:ApplicationDataProxy = ApplicationDataProxy(facade.retrieveProxy(ApplicationDataProxy.NAME));
   list.addEventListener(CustomColorEvent.UPDATED_COLOR, colorClickHandler);
   list.addEventListener(CustomMenuEvent.CHECK_CLICKED, checkClickHandler);
   list.addEventListener(MouseEvent.CLICK, clickHandler);
   list.itemRenderer = new ClassFactory(FlightItemRenderer);
   list.dataProvider = proxy.flightsList;
  }

  protected function colorClickHandler(event:CustomColorEvent):void
  {
   sendNotification(ApplicationFacade.UPDATE_COLOR, {id:event.data, color:event.color});
  }

  protected function checkClickHandler(event:CustomMenuEvent):void
  {
   sendNotification(ApplicationFacade.SHOW_FLIGHT, {id:event.data, visible:event.visible});
  }

  protected function clickHandler(event:Event):void
  {
   // also gets fired from colours and checkbox, BUT I DON'T WANT IT TO!!!
  }

将单击侦听器添加到项目呈现器中,并检查event.target属性以查看是否单击了复选框,如果是,则可以调用。下面是一个非常简单的示例,MouseEvent.CLICK的其他侦听器都不会被激发

<s:List>
    <s:itemRenderer>
        <fx:Component>
            <s:CheckBox click="checkbox1_clickHandler(event)" />
                <fx:Script>
                    <![CDATA[
                        protected function checkbox1_clickHandler(event:MouseEvent):void
                        {
                            //You could also add this click listener
                            //to the renderer itself if you need to do
                            //something when the checkbox is clicked
                            event.stopImmediatePropagation();
                        }
                    ]]>
                </fx:Script>
        </fx:Component>
    </s:itemRenderer>
</s:List>

感谢您的回复,这正是我想要的,以前从未使用过,但我知道。