Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.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 3:通过UIComponent引用取消选择切换按钮_Apache Flex_Button_Toggle_Uicomponents - Fatal编程技术网

Apache flex Flex 3:通过UIComponent引用取消选择切换按钮

Apache flex Flex 3:通过UIComponent引用取消选择切换按钮,apache-flex,button,toggle,uicomponents,Apache Flex,Button,Toggle,Uicomponents,我有一些按钮的切换设置为真。我正在尝试将按钮的状态重新设置为未选中。但是,我不能像:button.selected=false那样直接访问按钮 我正在访问HBox的孩子们,他们是按钮。UICOM组件没有选定的属性。那么,如何在下面这段代码中取消选择切换 for (var j : int=0; j < theHBox.numChildren; j++){ var child : DisplayObject = theHBox.getChildAt(j); var myButton

我有一些按钮的切换设置为真。我正在尝试将按钮的状态重新设置为未选中。但是,我不能像:button.selected=false那样直接访问按钮

我正在访问HBox的孩子们,他们是按钮。UICOM组件没有选定的属性。那么,如何在下面这段代码中取消选择切换

for (var j : int=0; j < theHBox.numChildren; j++){
   var child : DisplayObject = theHBox.getChildAt(j);
   var myButton:UIComponent = child as UIComponent;
   myButton.setStyle("borderColor", "blue");
   myButton.visible = true;
   } 
for(var j:int=0;j
如果可能,我建议将UIComponent强制转换为按钮:

for (var j : int=0; j < theHBox.numChildren; j++){
   var child : DisplayObject = theHBox.getChildAt(j);
   if(child is Button){
    var myButton:Button = child as Button;
    myButton.setStyle("borderColor", "blue");
    myButton.visible = true;
   } else if(child is somethingElse){
     // do something else
   }
} 
for(var j:int=0;j
你也可以这样做:

for (var j : int=0; j < theHBox.numChildren; j++){
   var child : DisplayObject = theHBox.getChildAt(j);
   var myButton:UIComponent = child as UIComponent;
   myButton.setStyle("borderColor", "blue");
   myButton.visible = true;
   myButton['toggle'] = false;
} 
for(var j:int=0;j

如果所有子项都是按钮,则该选项将起作用,但如果“myButton”没有toggle属性,则会引发运行时错误。

您好Flextras.com,非常感谢您的帮助。我使用了选项1。我能够摆脱UIC组件。因此,我将行更改为var myButton:Button=child-as-Button。我使用的代码的其余部分没有改变。再次感谢。很好地理解了我的打字错误。当我在浏览器中编写代码时,有时会发生这种情况。我会在我的回答中修正它。很乐意帮忙!