Get URL query-string variables within Flex application

[Abdul Qabiz’s Blog – India] 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 (requires server in place)

name and age are the query-string variables.

You can get the values of the params using from mx.core.Application.application.parameters object, which contains the name-value pairs (hash-map).

If your SWF is embedded in a HTML wrapper, the solution is to use ExternalInterface class in Macromedia Flash Player 8(onwards) to invoke some JavaScript functions and extract the value in ActionScript.

[ Demo | Source |

13 Responses to Get URL query-string variables within Flex application

  1. Prasanta Saha says:

    is it possible to get the query string if it is embedded in HTML

  2. aidawanz says:

    use your brain when u ask a question, jerk!
    first read the article.

  3. udayms says:

    I guess I should have made the post more clear. I will update the post with some more information 🙂

  4. udayms says:

    Prasanth… check it out now 😉

  5. seassymible says:


    VIAGRA, CIALIS, PHENTERMINE, SOMA… and other pills!

    Welcome please:


    Welcome please:


  6. hfrmevj gkcyrh cnmka nusqp ohwcp qcazi jurmndcfl

  7. Abstract: We describe the LHCb detector simulation application (Gauss) based on the Geant4 toolkit. The application is built using the Gaudi software framework, which is used for all event- processing applications in the LHCb experiment. The existence of an underlying framework allows several common basic services such as persistency, interactivity, as well as detector geometry description or particle data to be shared between simulation, reconstruction and analysis applications. The main benefits of such…

  8. chikadibia says:

    I am new to flex…
    pls. i need ur assistance on this.
    i have two flex mxml files.

    I want to pass a variable from mxml a to another b, pls. how do i go about it. am really stuck here. pls. assist.

    • Diki says:

      Thanks everybody for the cotmmnes. Matt, I’ll look around a bit more at stuff but it seems Renaun has some great advice there on how to fix the problem. I’m using Flex Builder so I’ll check the properties. The only thing I wonder though is what else changing the locale will do.. I mean, will it affect anything else?Ryan, great advice on the h and vboxes. I used those for a mockup of something else I was messing with but wasn’t really sure I needed them in the calculator app.

  9. Aksolut says:

    You have to use the ExternalInterface method when SWF is embedded in a html file, but for a standard SWF execution, application.parameters is better.

    Then you can combine two methods to get urlParameters in all case like this :

    private function getUrlParamaters():Dictionary
    var urlParams:Dictionary = new Dictionary();

    if (ExternalInterface.available)
    var fullUrl:String =‘eval’, ‘document.location.href’);
    var paramStr:String = fullUrl.split(‘?’)[1];
    if (paramStr != null)
    var params:Array = paramStr.split(‘&’);
    for (var i:int=0; i < params.length; i++)
    var kv:Array = params[i].split('=');
    urlParams[kv[0]] = kv[1];
    urlParams = Application.application.parameters;

    return urlParams;

  10. Thank you for this information. It helped me.

    var fullUrl:String =‘eval’, ‘document.location.href’);


  11. Ffean says:

    Wow, I’ve a webpage as well but I can’t write as well as you do. Fine stuff.

  12. Ewa Geanopulos says:

    This site is completely gret. I’ve ask these informations a great
    deal and I view it that is good written, fast to comprehend.
    I congratulate you because of this article that I am going to
    recommend to prospects friends. I ask you to visit the page where each learner or university student can find results
    gpa levels. All good!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: