5 Replies Latest reply on Jun 21, 2009 1:01 AM by *Prashant Shelke*

    CheckBox group

    Zolotoj Level 3

      Anything is available?

       

      Thanks

        • 1. Re: CheckBox group
          leybniz Level 4

          nope, and may I ask you what functionality are you expecting from this kind of container?

          probably you should go with the regular mx:Box?

          • 2. Re: CheckBox group
            Zolotoj Level 3

            I would say it should be a class with programmable numbers of checkboxes and their properties, and a method that will return an array or something with selected values.

            • 3. Re: CheckBox group
              leybniz Level 4

              I see, thanks, this way you'll have to relay on yourself only

              or you could take a look on that one

              http://robsondesign.com/blog/index.php/2008/12/23/checkboxgroup-20-beta/

              • 4. Re: CheckBox group
                Zolotoj Level 3

                I have put something together very quick. In case others need it:

                 

                package
                
                
                import flash.events.Event;
                
                import mx.containers.HBox;
                
                import spark.components.CheckBox;
                
                
                public class checkBoxGroup extends HBox{
                
                
                public var checkBoxNumber:int = 0;
                
                private var chkBox:CheckBox;
                
                private var _dataProvider:Object;
                
                public function checkBoxGroup(){
                
                
                super();}
                
                
                override protected function createChildren():void{
                
                // add as many checkboxes as developer has set via checkBoxNumber
                for (var i:int=0;i<checkBoxNumber;i++){
                chkBox = 
                
                new CheckBox();chkBox.name = i.toString();
                chkBox.addEventListener(
                
                "change", onClick);addChild(chkBox);
                } 
                validateNow();
                }
                
                
                public function set dataProvider(dataObj:Object):void{
                _dataProvider = dataObj;
                
                for (var i:int=0;i<checkBoxNumber;i++){
                CheckBox(getChildAt(i)).selected = Boolean(Number(dataObj[i].selected)); 
                CheckBox(getChildAt(i)).label = dataObj[i].label.toString(); 
                }
                }
                
                
                public function get dataProvider():Object{
                
                
                return _dataProvider;}
                
                
                //called by click of the checkbox
                private function onClick(event:Event):void{ 
                
                //set the checkbox state into the dataProviderdataProvider[Number(event.target.name)].selected = String(event.target.selected); 
                } 
                }
                }
                
                
                
                
                
                
                
                
                 modulecode{
                
                


                implementation:

                <modulecode:checkBoxGroup

                 

                checkBoxNumber="4"/>

                 

                data structure:

                <?xml version = "1.0" encoding="Windows-1252" standalone="yes"?>
                <VFPData>
                <customertype>
                  <id>1</id>
                  <label>RETAIL</label>
                  <selected>0</selected>
                </customertype>
                <customertype>
                  <id>2</id>
                  <label>CATALOG</label>
                  <selected>0</selected>
                </customertype>
                <customertype>
                  <id>3</id>
                  <label>HOSPITALITY</label>
                  <selected>0</selected>
                </customertype>
                <customertype>
                  <id>4</id>
                  <label>WEB</label>
                  <selected>0</selected>
                </customertype>
                </VFPData>