title: How to access html request parameters in external mxml
body: <p>From an HTML form, I wish to launch my existing working flex application passing in parameters E.G, login details.</p>
  
  <p>Lets say I have a simple HTML page with no FLASH in it at all.</p>
  
  <pre><code>&lt;h1&gt;Test sending parameters&lt;/h1&gt;
    &lt;form name="login" action="http://example.com/myflexApp/index.html" 
                               target="_new" method="POST"&gt;
    username: &lt;input type="text" name="username"  /&gt;
    password: &lt;input type="text" name="password"  /&gt;
    &lt;input type="submit" value="Submit" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>This will open up my application for the first time in a new browser window</p>
  
  <p>My index.mxml which is compiled to create index.html looks like this (simplified):</p>
  
  <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt;
   &lt;s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
             xmlns:s="library://ns.adobe.com/flex/spark"
             ...
             creationComplete="init(event)" xmlns:omp="omp.*"&gt;
     &lt;fx:Style source="defaults.css"/&gt;
     &lt;fx:Script&gt;
      &lt;![CDATA[
          import ...
  
          protected function init(event:FlexEvent):void
          {
            if (params[username] &amp;&amp; params[password])//psuedo code
            {
               Alert.show(params[username],params[password]);//debugging
               //login(params[username],params[password]);//psuedo code to log in automatically
            }else{
             //existing code to show login form which works
            }
          }
      ]]&gt;
     &lt;/fx:Script&gt;
     &lt;mx:ViewStack id="vs" width="100%" height="100%" ...&gt;
     &lt;/mx:ViewStack&gt;
   &lt;/s:Application&gt;
  </code></pre>
  
  <p>So what should the html code look like and what is the corresponding actionscript code that goes into the init() function?</p>
  
  <p>Or, at least what should I be googling for?</p>
  
  <p>Note: Obviously it is not acceptable to have the parameters and values showing in the browser's URL address. Otherwise this would be easy.</p>
  
  <p>Also note, the application is not embedded in the original HTML page, although 99.9% of search results I found on this topic gives an example of what to do if it was.</p>
  
  <p>Ideally the original request would be a POST request but apparently flex can't handle post requests.</p>
  
  <p>I've tried flashvars to no avail (although not entirely sure of the HTML format if it's not sending to an embedded SWF inside the HTML - and like I said, found 100's of examples if it was)</p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;param name="flashvars" value="test='default text'" /&gt;
  </code></pre>
  
  <p>MXML:</p>
  
  <pre><code>if (FlexGlobals.topLevelApplication.parameters.hasOwnProperty("username"))
  {
   Alert.show(FlexGlobals.topLevelApplication.parameters.username);
  }
  
  //Alert.show(LoaderInfo(this.root.loaderInfo).parameters.username);//also fails
  </code></pre>
  
  <p>So simple in most other languages I've worked with but having no luck with FLEX. I'm obviously missing something basic.</p>