Skip to main content
Participant
July 19, 2006
Question

Swap text in input text box

  • July 19, 2006
  • 1 reply
  • 326 views
I have a text box created with the text tool and I need it to change any spaces typed into it into the universal space code, %20. It would be best if the spaces could be changed instantly as they were typed, but it will also be acceptable if they are changed on a button release.

Please provide a snippet of ActionScript that will accomplish this and tell where I should put it (i.e. on text box, on button, on frame).
This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
July 19, 2006
try:

Inspiring
July 19, 2006
I think this won't work after the first replacement, because %20 are 3 letters, so indexVar should be increased by 3 when a space was replaced. Besides that, the text can't be edited.
Maybe this might be better:

yourTF.onChanged=function(){
yourTF.text = yourTF.text.split(" ").join("%20");
}

greets,
blemmo
Participant
July 20, 2006
-deleted-