Posted By

Activetuts on 01/13/11


Tagged


Versions (?)

Who likes this?

12 people have marked this snippet as a favorite

chus
elbjoern
toxin20
ichnoweb
kure69
AndrewPotter
JaaQ
souellette
elderhsouza
viver
coutlasssupreme
flashdeveloper


Space Removal


 / Published in: ActionScript 3
 

URL: http://enva.to/e4ig6z

In the same way you often need to format data being sent from Flash, you sometimes need format data being received. This function takes a string and removes all spaces from it. Here we use the split method of the String class to split the string into an Array and then call the join method of the Array class to convert it back to a string. This is useful when dealing with a string you know cannot contain spaces such as an email address, URL or phone number. This returns a new string, leaving the input string unchanged.

  1. function stripSpaces(string:String):String
  2. {
  3. var s:String = string;
  4. return s.split(" ").join("");
  5. }

Report this snippet  

You need to login to post a comment.