views:

56

answers:

2

I've spent a day on this so far and just can't figure it out. The problem is that Flash is apparently substituting & for & in my GET query params.

So for example, I'm sending into a URLLoader a URLRequest with a url similar to this:

http://foo.blah.com/app/index.php?abc=def&ghi=jkl&mno=pqr

I verified this by looking at the var in the debugger. Yet it's failing on our server. Ethereal reports that what is actually going over the wire is this:

GET /app/index.php?abc=def&ghi=jkl&mno=pqr

Not the first, but the second & is being replaced with &.

I can't figure out how to make it stop doing this. What could cause this? Or does anyone have any ideas of things I can investigate?

+1  A: 

Use the data property to construct the passed GET variables (you will have to set the request method to GET as well, check out the AS3 documentation for more granular information).

example :

var getVars:URLVariables = new URLVariables();
getVars.abc = "def";
getVars.ghi = "jkl";

var request:URLRequest = new URLRequest();
request.data = getVars;

urlLoader.load(request);
Theo.T
A: 

Ugh. Ok, thanks to Theo (who I'll give credit for the answer because I didn't know about URLVariables) I went and checked every possible thing that could be wrong.

The real problem was that I do indeed have & in the original URL request. I was doing a string.replace() that of course only hits the first instance.

The problem was that in the debugger, Flash apparently helpfully converts & back to &! So I didn't see the bug. Thanks Flash!

If I had done a trace() on the output just to be sure (which I thought I had but I clearly hadn't) then I would have noticed this.

Scott Bilas
str.replace(/foo/g, "bar") will replace all instances of "foo" with "bar.
Glenn