Flex 3:通过 UIComponent 参考取消选择切换按钮
我有一些按钮的切换设置为 true。我正在尝试将按钮的状态重新设置为未选择。但是,我无法直接访问该按钮,例如:button.selected=false。
我正在访问 HBox 的子项,即按钮。 UIComonent 没有选定的属性。那么,如何取消选择下面这段代码中的切换呢?
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;
}
I've got some buttons that have toggle set to true. I'm trying to re-set the button's state to unselected. But, I can't access the button directly like: button.selected=false.
I'm accessing the HBox's children which are the buttons. UIComonent doesn't have a selected property. So, how do I de-select the toggle in this bit of code below?
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;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果可能,我建议将 UIComponent 转换为按钮:
您也可以执行以下操作:
如果所有子项都是按钮,则这将起作用,但如果“myButton”没有切换属性,则会引发运行时错误。
If possible, I would recommend casting the UIComponent to a button:
You could also do something like this:
Which will work if all children are buttons, but if the 'myButton' does not have a toggle property, it will throw a run time error.