6 Replies Latest reply on Apr 27, 2007 10:35 PM by thedex1

    Dynamic UI

    thedex1 Level 1
      Hi,
      I want to ask you if it is possible to create a specific control, for example, "Text" dynamically. The user will be ask to specify the number of Text components to create and then the components are created accordingly.

      I really need help with this. I shall be very thank full to you.

      Regards
      .:.Wahab
        • 1. Re: Dynamic UI
          TigerArt Level 1
          you will create them for a database or not ?
          • 2. Re: Dynamic UI
            thedex1 Level 1
            hi,
            Thank you for your response. My data is coming from XML file. Here is a sample XML File:
            <slides>
            <slide id="1">
            <image>images/magnifyingMan.jpg</image>
            <headingText>Think again</headingText>
            <descText>about your Health and Fitness</descText>
            </slide>
            <slide id="2">
            <image>images/womanInExer.jpg</image>
            <headingText>Exercise for Beginners</headingText>
            <descText>Learn how to get started on your exercise program from your Health.com</descText>
            </slide>
            <slide id="3">
            <image>images/oranges.jpg</image>
            <headingText>Eat healthy</headingText>
            <descText>Good nutition and a balanced diet will help you and your child grow up healthy</descText>
            </slide>
            </slides>

            And I am using "States" to navigate from one image to another. Now if I want to add another node to my XML file, my question is, how can I reflect this change to my states dynamically without manually changing the MXML file.

            I really thank you for your response. Kindly help me if you can.

            Thanks,
            Regards
            .:.Wahab
            • 3. Re: Dynamic UI
              GMina
              Yes it is simple, but needs to be done in AS and not MXML. Here is a very simple example that shows how to create new components with AS, as well as programatically configure databinding on those components.


              <?xml version="1.0"?>
              <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml">

              <mx:Script>
              <![CDATA[
              import mx.controls.TextInput;
              import mx.binding.utils.BindingUtils;

              [Bindable]
              public var bindingText:String = "Hello World";

              private function addTextInput():void{
              var textInput:TextInput = new TextInput();

              /** set any attributes here */
              textInput.width = 200;

              /** configure any data binding */
              BindingUtils.bindProperty(textInput,"text",this,"bindingText");

              /** add the new component to the specified container */
              this.sourceView.addChild(textInput);

              }
              ]]>
              </mx:Script>

              <mx:VBox id="sourceView" width="100%" height="100%">
              <mx:HBox width="100%">
              <mx:Button label="Add New Text Input" click="addTextInput()"/>
              <mx:Button label="Change Bound Text" click="this.bindingText='Good Bye World!'"/>
              </mx:HBox>
              </mx:VBox>
              </mx:Application>
              • 4. Re: Dynamic UI
                thedex1 Level 1
                Dear GMina, thank you very much. I really thank you. I have a very similar question.
                One of the top most problem I am facing is working with XML and Button. Can you please assist me in this. I am explaining my problem:

                I have an external XML file like this:
                <Menu>
                <button>
                <idnt>0</idnt>
                <label>General Health</label>
                <text>General Health pages is currently under construction</text>
                </button>
                <button>
                <idnt>1</idnt>
                <label>Mental Health</label>
                <text>Mental Health pages is currently under construction</text>
                </button>
                </Menu>

                Now I want to generate Buttons Dynamically from this XML. And the second thing which is the most problematic is that how I code it so that when I press the Button labled "General Health", it will show the same text as in the XML tag coresponding to tag "<label>General Health</label>" ?
                I badly need this. I am realy confused on this. Kindly help me.

                Regards
                ..::DeX
                • 5. Re: Dynamic UI
                  rajeeva_nagaraj
                  Hi

                  You can use repeaters to generate controls dynamically

                  regards
                  Rajeev
                  • 6. Re: Dynamic UI
                    thedex1 Level 1
                    Dear Rajeeva,

                    Thank you for your response. I want to tell you that, yes we can use repeater to do this but I find it little easier to solve this problem with AS. Anyway, thank you for your response.
                    My MSN account ID is "de.xsense@hotmail.com". I would greatly appreciate if either you add me to your contact list or let me know your email address. I am not asking your hotmail ID to ask you a lot of questions, just would like to be a friend to share new ideas and knowledge.

                    Thank again...

                    Regards
                    ..::DW