This seems like it must be ridiculously easy to fix, which is why is it is so frustrating. Essentially actionscript seems to be unable to find question marks in a string (and I have found it responds oddly to periods as well).
I am writing a simple script to append query variables to a URL and need to know if there are already variables there (meaning it already has a question mark in the URL). If it doesnt, it adds the variable with a question mark before it, if it does then it adds the variable with a ampersand before it.
Here is some code with the return values commented next to it. You’ll notice the ? and . returns are always incorrect. I haven’t found any documentation on this, and I am wondering if I have some kind of setting wrong or something.
var targetUrl = "http://mysite.com?SID=1";
trace(targetUrl,targetUrl.search("?"))//return http://mysite.com?SID=1, -1
var q:String="?.!"
trace(q) //return ?.!
trace(q.search("?"))//return -1
trace(q.search("."))//return 0
trace(q.search("!"))//return 2
var a:String=".?!"
trace(a.search("."))//return 0
trace(a.search("?"))//return -1
trace(a.search("!"))//return 2
var b:String="!?."
trace(b.search("!"))//return 0
trace(b.search("?"))//return -1
trace(b.search("."))//return 0