使用actionscript取消选中组件中的复选框?

时间:2011-03-22 17:45:58

标签: flex actionscript checkbox components

我有一个带复选框的组件,复选框绑定到主代码中的布尔值:

<mx:CheckBox id="LyrClearAll" selected="{Application.application.bLyrClearAll}"/>  

除非用户再次与它们交互,否则这对于不会更改的复选框很有效。出现我的问题是因为我想在每次关闭组件时“取消选中”其中一个框。 (我知道除了复选框之外的其他东西会更好,但我试图在这个组件中保持一致。)

我尝试将绑定的布尔变量设置为false,并且我尝试将checkbox.selected值设置为false。两者都没有工作,每次打开组件时仍然会选中复选框。

private function makeLyrsPopUp(evt:MouseEvent):void  
{  
  var panelLyr:popUpLayers = PopUpManager.createPopUp(this, popUpLayers, false) as popUpLayers;    
  panelLyr.LyrClearAll.selected == false; //?? set checkbox back to unchecked 
  panelLyr["cancelButton"].addEventListener("click", removeMe);
  panelLyr["okButton"].addEventListener("click", submitData);
  PopUpManager.centerPopUp(panelLyr);

  function submitData(event:Event):void  //change layer visibility based on check boxes in popupLayer
  {
    bLyrStreet = panelLyr.LyrStreet.selected;
    bLyrParcel = panelLyr.LyrParcel.selected;
    bLyrClearAll = panelLyr.LyrClearAll.selected;
    if (bLyrClearAll)
    {
      clearLayers();
      bLyrClearAll == false;  //?? set checkbox back to unchecked
    } 
    removeMe(event);
  }
} 

2 个答案:

答案 0 :(得分:2)

需要将== false更改为= false

答案 1 :(得分:1)

bLyrClearAll应声明为可绑定:

[Bindable]
var bLyrClearAll: Boolean;