On flexcoders, someone asked, how to get the URL parameters in a Flex 2.0 application? By URL parameter, I mean the query-string variables, as shown below:
http://yourserver/yourapp.swf?name=Joe&age=22 or http://yourserver/yourapp.mxml?name=Joe&age=22
Note: To get the variables in flex via mxml file, you need server-side compilation of mxml files.
You can get the values of the params using from
object, which contains the name-value pairs (hash-map).
would return “Joe”, considering above example URL. You can find more information about this in livedocs: http://livedocs.macromedia.com/flex/20beta1/docs/00001300.html
Then someone asked, what if your swf is embedded in custom html wrapper, how to get the query-string params inside swf?
QueryString class has following properties:-
parameters – an Object which contains the name-value pairs from query-string
queryString– String, this contains the entire query-string (url-encoded) name-value pairs.
url– String, this returns the complete URL of the wrapper page with query-string.
Download source files