Search code examples
flashactionscriptactionscript-2query-stringflashvars

How to pass flashVars in to Flash and then back out as a query string


I am asking this question as a complete Flash novice, so please do point out if I'm doing anything wrong here (I suspect I am).

I have a Flash MPU size animation with a link in it which has been created by using a full sized transparent layer as a button (is that the correct way) with the following ActionScript:

on(release){
  getURL("/account/", "_self")
}

What I would like to do is pass some flashVars in to the Flash and then append them as a query string. I have tried a method like this:

on(release){
  var paramObj:Object = LoaderInfo(this.root.loaderInfo).parameters;
  getURL("/account/?test="+String(paramObj["test"]), "_self")
}

Two things. Firstly I don't think that is the correct way to retrieve the flashVar so I need a bit of help in that respect.

The second problem is that the relative URL being linked to is stripping out the entire query string - so I don't event get "/account/?test=undefined". So how do I actually append the query string to the URL?

Thanks for your help.


Solution

  • This is how I used Flashvars before in AS2

    Javascript

    <script type="text/javascript">
    
        var flashvars = {};
        flashvars.xmlPath = "/themixer/flash/mixerplayer.xml";
    
        // Rest of Flash code here
    
    </script>
    

    ActionScript-2

    var xmlFile:String = xmlPath;
    

    Then you can do whatever with xmlPath or whatever var you want to call it :) The XML file can be a string like in your case.