9 Replies Latest reply on Aug 23, 2006 1:59 PM by GeorgeWS


    GeorgeWS Level 1
      I want to have a variable come into my flash app from a URL like: testapp.cfm?name=george

      then use the "name" in the RemoteObject to call out only the data that has name george. Also Id like to attach the name george to the linkbutton. what would this look like?

      <mx:LinkButton label="Download" width="100" click="navigateToURL(new URLRequest(' http://www.youngsmarket.com/youngsmarket/programs/inventory/test.cfm?name=george))" />

      im not sure how to set the variable and use it. like #session.name# in Cold Fusion.

        • 1. Re: variables
          peterent Level 2
          The Application class has a parameters property:

          Application.application.parameters.name would be "george' in this case because you had name=george.

          I would do the following:

          <mx:LinkButton label="Download {downloadLabel}" click="gotoURL()" />

          [Bindable] private var downloadLabel:String;

          private function initApp() : void {
          downloadLabel = Application.application.parameters.name;

          private function gotoURL() : void {
          var url:URLRequest = new URLRequest(" whatyouhavenow"+Application.application.parameters.name);

          Call the initApp() method from the creationComplete event on the container (root) tag.
          • 2. Re: variables
            GeorgeWS Level 1
            I could not get <mx:Link to work, not sure if its a component? So I used LinkButton
            and Im not sure about the line under the private function gotoURL where you put "whateveryouhavenow", I put my whole url string with the "?name="+App... ?

            and the url that goes to the page should look like?

            Thanks for looking
            • 3. Re: variables
              peterent Level 2
              Yes, Link is wrong, it was supposed to be LinkButton; I'll edit the entry to make it right.

              I meant for you to put the URL you already have, minus the george part because you have to form that with ActionScript:

              URLRequest(' http://www.youngsmarket.com/youngsmarket/programs/inventory/test.cfm?name="+
              • 4. Re: variables
                GeorgeWS Level 1
                I can see that it should work. I see the button with the label Download but it really says Downloadnull. So I am sure I am not passing in the variable "name" Im not sure how to push the variable into the Application parameters? like this?

                • 5. Re: variables
                  GeorgeWS Level 1
                  If I pass in a variable like test.cfm?name=george

                  how do I display the variable name in my flex app?
                  • 6. Re: variables
                    peterent Level 2
                    I'm not sure how well data binding will work with the Application.parameters object; it may work and you will get warnings or nothing will show up (or the compiler will give you an error):

                    <mx:Text label="{Application.application.parameters.name}" />

                    This will work:
                    <mx:Text id="myname" />
                    in ActionScript:
                    myname.text = Application.application.parameters.name;

                    Or you can write a function to handle the creationComplete event (of whatever the root tag is on the component where you want to display the name) and do:

                    <mx:VBox creationComplete="saveVars()" >
                    [Bindable] private var myName:String;
                    private function saveVars() : void
                    myName = Application.application.parameters.name;
                    <mx:Text text="{myName}" />

                    This last choice is, in my opinion, the best.
                    • 7. Re: variables
                      GeorgeWS Level 1
                      Thanks for the response, but I am very dense. neither solution works. I have this as my first line in my app:
                      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="vertical" creationComplete="initApp()" >
                      so I am already using the creationComplete. I dont know why this is so hard, why 6 lines of code to get one variable; seems crazy. I dont understand the first example, where do I put the line myname.text = Application.application.parameters.name
                      and then the <mx:Text id="myname"/> goes in the panel with the rest of the stuff?
                      • 8. Re: variables
                        peterent Level 2
                        No problem.

                        When you say "how do I display the variable name in my flex app?" I didn't really know what you meant. Do you mean in a Text control? Or a Label control? Or the label on a Button?

                        Wherever or whatever it is, using Application.application.parameters.name will retrieve the variable, name, from the request. I am assuming from the start of this thread, that you were doing:


                        and then you want to display the value of 'name' in the Flex app as well as pass it along to a CFM.

                        What that not the right assumption?
                        • 9. Re: variables
                          GeorgeWS Level 1
                          You are correct in all of what I want. But Im not realley getting anywhere so I decided to ask smaller questions. In your last post I see that you have an address and it goes to a .mxml Is that where my app should be going? I have my app going to the html file.
                          I tried putting:
                          <mx:Text text="Hi{Application.application.paramerters.name}"/> so i could see the name HIgeorge show in a panel but instead I get Hiundefined.
                          Is there something else that I need along with the <mx:Text text="Hi{Application.application.paramerters.name}"/> line?