Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/9.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
Apache flex 我如何解决flex中的空组件问题?_Apache Flex_Flex4_Flex4.5 - Fatal编程技术网

Apache flex 我如何解决flex中的空组件问题?

Apache flex 我如何解决flex中的空组件问题?,apache-flex,flex4,flex4.5,Apache Flex,Flex4,Flex4.5,我有一个组件“child”,它有一个取消按钮。 现在,该组件处于一个名为“newChildComp”的状态 我还有另一个组件叫做“父”。在父组件中,我有一个发送事件的按钮。以下是事件代码: protected function addNewChild(event:Event):void { if(currentState!='newChildComp') currentState='newChildCom['; child["cancelButtonId"].addEventLi

我有一个组件“child”,它有一个取消按钮。 现在,该组件处于一个名为“newChildComp”的状态

我还有另一个组件叫做“父”。在父组件中,我有一个发送事件的按钮。以下是事件代码:

protected function addNewChild(event:Event):void
{
 if(currentState!='newChildComp')
   currentState='newChildCom[';
    child["cancelButtonId"].addEventListener("click",cancelButtonHandler);
}
因此,基本上,我正在检查子组件中的cancel button组件(我仍然在父组件中)是否被单击,如果被单击,则调用cancelButtonHandler。问题是在addNewChild处理事件时,cancel按钮仍然为空。我的问题是,如何在不使用“取消”按钮上的itemCreationPolicy的情况下解决此问题


谢谢

您可以在mxml中添加click属性

<s:Button click="cancelButtonHandler(event)" />

或者,如果您不想这样做,请将事件侦听器添加到容器上的creationComplete或contentCreationComplete,并在其中添加事件侦听器

<s:WhateverComponent includeIn="newChildComp" contentCreationComplete="{cancelButton.addEventListener etc.}"/>

这有意义吗