3 Replies Latest reply on Sep 10, 2007 2:00 PM by jfuentes3002

    Checkbox List

      I'm getting data from a XML through a HTTPService.
      how can I make a checkbox list?
      how can I make a ckeckbox "select/unselect all"?
      (sorry about my terrible english)
        • 1. Re: Checkbox List
          JKohn99 Level 1
          You need to use an itemRenderer.

          Below is an example in mxml. For this example, the data must have a selected:Boolean property.

          <?xml version="1.0"?>
          <!-- itemRenderers\list\myComponents\RendererState.mxml -->
          <mx:HBox xmlns:mx=" http://www.adobe.com/2006/mxml" width="100%" height="100%">
          <mx:Script>
          <![CDATA[
          private function doSelection():void
          {
          if(cb.selected == true)
          data.selected = true;
          else
          data.selected = false;
          }
          ]]>
          </mx:Script>

          <!-- Define the Link control to open a URL. -->
          <mx:CheckBox x="6" y="6" id="cb" click="doSelection()" width="19" selected="{data.selected}"/>
          <mx:Label id="State" text="{data.label}" />
          </mx:HBox>
          • 2. Re: Checkbox List
            Level 1
            There you show me the example of the component. How can I make a ckeckbox "select/unselect all"?
            • 3. Re: Checkbox List
              Level 1
              Hello. I have generated my checkbox list through a TileList in a component page.

              If I have 10 checkboxes, how can I know the state of de checkbox Nº 5 and Nº6?

              My idea is handle each checkbox separately.

              This is the Principal Page
              ====================
              <?xml version="1.0" encoding="utf-8"?>
              <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="{initVars()}">

              <mx:Script>
              <![CDATA[
              import mx.controls.Alert;
              import mx.rpc.events.*;
              import mx.utils.ArrayUtil;

              private function initVars():void
              {
              xmlVariedades.send();
              }

              private function DataXMLHandler(event:ResultEvent):void
              {
              if(event.result.variedades == null)
              {
              mx.controls.Alert.show("No hay datos de Variedades");
              }
              }
              ]]>
              </mx:Script>

              <mx:HTTPService id="xmlVariedades"
              url=" http://test.tide.cl/jfuentes/sanjosefarms/sgp_2006/gestion_huertos/xml_variedades.php"
              useProxy="false"
              method="GET"
              result="DataXMLHandler(event)">
              <mx:request xmlns="">
              <id_huerto>1</id_huerto>
              <muestra_todas>true</muestra_todas>
              </mx:request>
              </mx:HTTPService>

              <mx:ArrayCollection id="ACVariedad" source="{ArrayUtil.toArray(xmlVariedades.lastResult.variedades.variedad)}"/>

              <mx:Panel x="828" width="245" height="534" layout="absolute" title="Panel de Opciones" id="pOpciones">
              <mx:Accordion width="100%" height="100%">
              <mx:Canvas label="Producto" width="100%" height="100%">
              <mx:Label text="en construcción"/>
              </mx:Canvas>
              <mx:Canvas label="Variedades" width="100%" height="100%">

              <mx:TileList id="ListaVariedades" dataProvider="{ACVariedad.getItemAt(0)}"
              backgroundColor="#FFFFFF" width="220" height="100%" columnWidth="220" rowHeight="20"
              selectionColor="#FFFFFF" rollOverColor="#FFFFFF" disabledColor="#FFFFFF" borderThickness="0"
              itemRenderer="componentes.MuestraImgVariedad"/>

              </mx:Canvas>
              </mx:Accordion>
              </mx:Panel>

              </mx:Application>

              This is the Component Page
              ======================
              <?xml version="1.0" encoding="utf-8"?>
              <mx:HBox xmlns:mx=" http://www.adobe.com/2006/mxml" width="400" height="300">

              <mx:CheckBox id="cbItem" name="{data.var_id_variedad_num}" toolTip="{data.var_nombre_txt}" click="doSelection(event)"/>
              <mx:Image source="{'colores/'+data.color+'.jpg'}"/>
              <mx:Label text="{data.var_nombre_txt}"/>

              </mx:HBox>