Removing spaces from a string is really easy in Actionscript 3. One method is to simply convert the string to an array using the String.split() function using a space as the delimiter. Then you can use the Array.join function to put it all back together again without the spaces.
Here is a simple function that will do the trick:
1 2 3 4 5 6 | public function removeSpaces(input:String):String { var split:Array = input.split(" "); var output:String = split.join(""); return output; } |
That’s it!
example:
1 2 | trace(removeSpaces("ABCD EFG HI JKLMNOP QRSTU VWXYZ")); // outputs: ABCDEFGHIJKLMNOPQRSTUVWXYZ |








