0

I found this post and I used the code almost exactly to how they suggested. It doesn't work. Do I need to add something in the php? What am I doing wrong? Am I missing an import?

Thanks

Here is my code:

my php link is: www.mySite.com/example.php?id=true

var search:String = ExternalInterface.call("window.location.search");
var vars:URLVariables = new URLVariables(search);

if(vars.id)
{
    /// Do something
}

Found answer here but doesn't work for me. How to get/obtain Variables from URL in Flash AS3

Community
  • 1
  • 1
Papa De Beau
  • 3,744
  • 18
  • 79
  • 137
  • Are you embedding the .swf file using SWFObject? If yes, did you set `allowscriptaccess:"always"`? http://helpx.adobe.com/flash/kb/control-access-scripts-host-web.html – Khôi Oct 22 '12 at 21:25
  • I did embed it. I changed it to always and it still is not reading the url. Using firefox. Not sure if this matters. – Papa De Beau Oct 22 '12 at 23:25

1 Answers1

0

You forgot to get rid of the page address:

var search:String = "www.mySite.com/example.php?id=true";
var vars:URLVariables = new URLVariables(search.substr(search.indexOf("?")+1));

if(vars.id) trace(vars.id);

Provided that you are sure that the address contains ? and actual variables you are looking for.

Valentin Simonov
  • 1,768
  • 10
  • 14
  • Thanks. I needed this so it can read the vars in the url and not have them hard coded in the flash.... var search:String = ExternalInterface.call("window.location.search"); But I can't get it to read the url. This is my main issue. – Papa De Beau Oct 22 '12 at 21:46