Flex 2: How to get URL query-string variables within Flex application
This has been a reoccurring problem on flexcoders and in the small circle of Flex developers I know. It is a problem that I had encountered and thought that I had found an answer; Abdul Qabiz's Blog posting (duplicated) had described a (in his own words) "quick-and-dirty" solution. That method works well for pulling the String value of the parameters passed in the query-string, but what do you do when those values are URL Encoded? Below is my (and I use my very loosely as it isn't much to claim) solution that provides similar behavior as described in Abdul's posting, but requires significantly less code and is much more readable:
Given the URL:
http://deepthoughts.orsomethinglikethat.com?myParam=My%20Value
the return value is "My Value".
This may not be the ideal solution if the URL is pointed directly to the SWF or if you choose to make your parameters available via FlashVars.
Comments(3)