Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Repacing the "Space Char" Flash 8

1 view
Skip to first unread message

Butchmu

unread,
Oct 20, 2007, 6:02:55 PM10/20/07
to
Would like to be able to replace the "Space Bar" space with "%20". I have an
address field that is filled in, and need to be able to replace the space with
"%20" in the actionscript. You guessed it my variable is "address", I think
that it should go something like this len(address) = len -1 if i = " " then i =
"%20" .... I'm sure someone has a sample piece of code that would work.

Thanks

kglad

unread,
Oct 20, 2007, 6:32:48 PM10/20/07
to
:

function replaceSpace(s:String):String{
return s.split(" ").join("%20");
}

Butchmu

unread,
Oct 20, 2007, 9:18:39 PM10/20/07
to
I thought I understood the code you provided, I normally just keep trying until
I get it or begin to understand it. I'm deadlocked on this. I'm providing the
code so that you may understand what I'm doing and possibly provide a little
more guidance.


Thanks

on (release) {

s = _root.address.text

function replaceSpace(s:String):String{
return s.split(" ").join("%20");
}


if ((_root.address.length>0) & (_root.city.length>0) & (_root.zip.length>0)) {
url =
"http://www.mapquest.com/directions/main.adp?go=1&do=nw&un=m&2tabval=address&cl=
EN&ct=NA&1tabval=address&1y=US&1a=" + s + "&1c=" + _root.city.text + "&1z=" +
_root.zip.text + "&2y=US" + "&2a=" + address_2 + "&2c=" + city_2 + "&2s=" +
state_2 + "&2z=" + zip_2 +
"&idx=0&id=410ed2bb-002ee-01b60-400c3301&aid=410ed2bb-002ef-01b60-400c3301";
getURL(url)
trace(url)
} else {
_root.error = "Error: Please fill out all text fields";
}
}

kglad

unread,
Oct 21, 2007, 12:59:51 AM10/21/07
to
if _root.address.text is a string whose spaces you want to url encode use:

on (release) {

s = replaceSpace(_root.address.text);


// and the code below appears incorrect. should these be checking the text
properties?

if ((_root.address.length>0) & (_root.city.length>0) & (_root.zip.length>0)) {
url =
"http://www.mapquest.com/directions/main.adp?go=1&do=nw&un=m&2tabval=address&cl=
EN&ct=NA&1tabval=address&1y=US&1a=" + s + "&1c=" + _root.city.text + "&1z=" +
_root.zip.text + "&2y=US" + "&2a=" + address_2 + "&2c=" + city_2 + "&2s=" +
state_2 + "&2z=" + zip_2 +
"&idx=0&id=410ed2bb-002ee-01b60-400c3301&aid=410ed2bb-002ef-01b60-400c3301";
getURL(url)
trace(url)
} else {
_root.error = "Error: Please fill out all text fields";
}
}

// attached to a frame:

Butchmu

unread,
Oct 21, 2007, 1:21:04 AM10/21/07
to
grin; Thanks, the above code worked perfectly:

Hope this also helps others on the forum.

Thanks

kglad

unread,
Oct 21, 2007, 1:33:48 AM10/21/07
to
you're welcome.
0 new messages