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

    Dynamic UI

      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.

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

            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.

            • 3. Re: Dynamic UI
              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">

              import mx.controls.TextInput;
              import mx.binding.utils.BindingUtils;

              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 */

              /** add the new component to the specified container */


              <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!'"/>
              • 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:
                <label>General Health</label>
                <text>General Health pages is currently under construction</text>
                <label>Mental Health</label>
                <text>Mental Health pages is currently under construction</text>

                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.

                • 5. Re: Dynamic UI

                  You can use repeaters to generate controls dynamically

                  • 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...