3 Replies Latest reply on Jan 4, 2007 5:27 AM by peterent

    How can I get parameter  like  swf?id=1

    Flex2.0ing...
      In flash 8 , I can get the value of "id" by using "_root.id", but in flex builder IDE, it won't compile successfully,how can I get the "id"
        • 1. Re: How can I get parameter  like  swf?id=1
          peterent Level 2
          If you have myapp.swf?id=1 as part of the URL to a Flex application SWF, you can get to id very easily:

          <mx:Application ... >

          <mx:Text text="You passed id={parameters.id}" />

          </mx:Application>

          The Application class has a property called parameters. This object's own properties are created from any query string values on the URL. In your case, it would create the property id on the parameters object.
          • 2. Re: How can I get parameter  like  swf?id=1
            wy790289
            Hi Peter,

            I try the example above it can get the parameters from the url, eg "myApp.swf?parm01=1". However, if I create the application using Flex Builder 2 and FB2 will also create a html file to me. If I open the html page with parameter, e.g. "myApp.html?param01=1", can the flex program call inside the html file get the parameters?

            Thanks,
            Wilson
            • 3. Re: How can I get parameter  like  swf?id=1
              peterent Level 2
              Flash cannot get at the request parameters from the HTML url. But there are several ways to get the parameters to the Flex app running in the Flash Player.

              One way is to take the HTML wrapper file and change it to a JSP. Then code the JSP to transfer the request parameters to the SWF url.

              Another way is to use the Flash ExternalInterface API in the Flex program. The ExternalInterface API can communicate with a JavaScript function in the HTML file. You would then have the JavaScript function read the request parameters and return them to the Flex programming running in the Flash Player.