Groups | Blog | Home
all groups > flash actionscript > april 2004 >

flash actionscript : Loading XML factoring in special characters


James Fee
4/5/2004 5:03:21 PM
You have to URL encode the string before sending it. This is done in
actionscript using the function escape() (and the corresponding unescape()
to decode). I would just escape the string right before you send it.

--
Jim Fee
Viking Electronic Services
jfee (at) vikinges (dot) com
[quoted text, click to view]

JAXIMFLASH
4/5/2004 8:40:25 PM
I am loading XML by calling a query string to a server. Because the XML is for
a search function, the user can type ANYTHING, which would be passed along to
this query strring.

What I am discovering is that if the user types one of at least 5 special
characters, (&:"#\), the function doesn't perform as expected. Is there anyway
to factor in special characters when loading XML?

Some ways I thought might work, but unsure how to implement:
1) Somehow use the POST method when loading the XML
2) call a javascript or actionscript function to encode the string, before
sending it as a query string in the XML.load function

Any ideas on solving this woulkd be sppreciated by not only me, but many
others who I'm sure are experiencing the same difficulties. I'll report back if
I discover anything myself.

Thanks in advance!




JAXIMFLASH
4/5/2004 9:14:18 PM
Within a matter of minutes, I solved my own problem, but hopefully this helps
others.

It was really simple, or really stupid, depending on how you look at it. If
you use the actionscript built-in function "escape()" to encode the string
before sending it, then that solves everything.

i.e. escape("Tom & Jerry")

I can't believe I missed that, but for some reason, the function wasn't in the
index of the Flash book I use: "Flash MX ActionScript Bible". I'm sure the
function is mentioned somewhere in the book but I can't seem to find it.



AddThis Social Bookmark Button