0

I need to send a query string from Flash so that it appears in address bar of a browser. Basically, I need to make a Flash version of this HTML code:

<a href="Portfolio.htm?image=4">link</a>

Seems simple... When I try to do this from Flash the browser cuts off the query string. So instead of getting Portfolio.htm?image=4, I only get Portfolio.htm This is the actionscript I am using:

var url:String = "Portfolio.htm";
var variables:URLVariables = new URLVariables();
variables.image = '4';
var newRequest:URLRequest = new URLRequest(url);
newRequest.data = variables;
newRequest.method = URLRequestMethod.POST;
navigateToURL(newRequest);

This actionscript works great when I click the button from the Flash player. It stops working when I try to put the swf into a HTML wrapper.

The query string image=4 is not going to PHP file. Portfolio.htm uses Javascript to strip the variable from the URL. Most of the questions surrounding this topic deal with PHP files and don't care if the query string appears in the browser address bar.

1 Answers1

1

Try changing the URLRequestMethod to GET instead of POST.

newRequest.method = URLRequestMethod.GET;

Or simply leave it out because GET is the default method.

pythonjsgeo
  • 5,122
  • 2
  • 34
  • 47
  • I have tried changing the URLRequestMethod to GET. I get the same result. The query string does not appear in the address bar when the swf is in a HTML wrapper. – user3594512 May 02 '14 at 00:36
  • Are you running this on the filesystem or on a website/localhost? The query string may be ignored if you are not running on a website/localhost. – pythonjsgeo May 02 '14 at 04:34
  • That worked! I was running it on the file system, once I moved it to my local host it worked just fine. I should have thought of that. Thanks for helping move beyond a couple of unproductive days! – user3594512 May 02 '14 at 18:11