0 Replies Latest reply on Mar 9, 2009 12:52 PM by ice9_us

    question about checkbox

    ice9_us
      http://actionscriptexamples.com/2008/12/01/creating-a-multiline-checkbox-component-in-flas h-using-actionscript-30/

      i am making a checkbox using the code below... I make a httpservice request to get a list of data...
      based on some things, i will make a checkbox... I am trying to make the checkbox show selected when i make it if it shows up in that list of data. If it doesn't show up i want to make the checkbox but show up as not selected... I can't figure out how to do that. right now in the code below i am trying to set <var>.selected = true;
      just to make it come up as selected and that doesn't work.

      mxml app:
      -- selecthboxenv.mxml

      private function checkBox_change(evt:Event):void {
      if ( Application.application.SelectedEnv.length == 0 ) {

      }
      for ( var a:int = 0; Application.application.SelectedEnv[a]; a++ );
      var ch:CheckBox = evt.currentTarget as CheckBox;
      //ch.selected ? mx.controls.Alert.show( ch.document.callme.toString() ) : null;
      ch.selected = true; // here i am trying to make the check box come up selected when mxml component is called.

      if ( Application.application.SelectedEnv.length == 0 ) {
      Application.application.SelectedEnv[0] = ch.document.callme;
      } else {
      for ( a = 0; Application.application.SelectedEnv[a]; a++ );
      Application.application.SelectedEnv[a] = ch.document.callme;
      }
      }

      ]]>
      </mx:Script>
      <mx:Repeater dataProvider="{callme}" id="EnvValues">
      <mx:CheckBox label="{EnvValues.currentItem}" click="checkBox_change(event);" />
      </mx:Repeater>
      </mx:HBox>




      thanks in advanced for any ideas or information.