4 Replies Latest reply on Jun 7, 2010 7:16 AM by kiran@flex

    what is the use of creating Custom UIComponnets like Comboboxes ??

    kiran7881 Level 1

      Hi ,


      I am having a query with respect to creating custom components , I have seen a number of examples where the sites
      providing example for how to create a Custom Combobox .

      But can anybody please let me know what would be the use of creating a Custom Component like a Combobox ??

      Please share your ideas on this .

      Thanks in advance.

        • 1. Re: what is the use of creating Custom UIComponnets like Comboboxes ??
          BhaskerChari Level 4

          Hi Kiran,

           

          Flex supplies a ComboBox control that you can use as part of a form that collects address information from a customer. In the form, you can include a ComboBox control to let the user select the state portion of the address from a list of the 50 states in the U.S. In an application that has multiple forms where a user can enter an address, it would be tedious to create and initialize multiple ComboBox controls with the same information about all 50 states.

          Instead, you create an MXML component that contains a ComboBox control with all the 50 states defined within in it. Then, wherever you need to add a state selector to your application, you use your custom MXML component. The following example shows a possible definition for a custom ComboBox control:

           

          <?xml version="1.0"?>
          <!-- intro\StateComboBox.mxml -->

           

          <!-- Specify the root tag and namespace. -->
          <mx:ComboBox xmlns:mx="http://www.adobe.com/2006/mxml">
              <mx:dataProvider>  
                  <mx:String>AK</mx:String>
                  <mx:String>AL</mx:String>
                  <!-- Add all other states. -->
              </mx:dataProvider>
          </mx:ComboBox>

          The main application, or any other MXML component file, references the StateComboBox component, as the following example shows:

           

          <?xml version="1.0"?>
          <!-- intro/IntroMyApplication.mxml -->

           

          <!-- Include the namespace definition for your custom components. -->
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:MyComp="*">

           

              <!-- Use the filename as the MXML tag name. -->
              <MyComp:StateComboBox/>

           

          </mx:Application>


          Hope this will make things clear.


          If this post answers your question or helps, please kindly mark it as such.


          Thanks,

          Bhasker Chari

          • 2. Re: what is the use of creating Custom UIComponnets like Comboboxes ??
            kiran@flex Level 1

            Hi Kiran,

             

            You can also use XML file to create comboboxes by putting less efforts in coding

            You can use Xml file containing all the objects for combobox and render them .

            It  helps to change all the data anytime we want without even going to code.

            • 3. Re: what is the use of creating Custom UIComponnets like Comboboxes ??
              SpaghettiCoder Level 3

              @Kiran you just said hi to yourself...

               

              Having a XML file containing all the objects is like making a DB call for the data...it's more work, and slower to instantiate than something simply all there.

               

              If your data doesn't change then custom component is good, but if it changes you may want to look at a different method.

              • 4. Re: what is the use of creating Custom UIComponnets like Comboboxes ??
                kiran@flex Level 1

                Hi SpaghettiCoder,

                I am talking about a bigger and effficient way where you can put more than
                1000 objects in combobox , by the way look at my username i am diffrent Kiran