Flex-Strings

Flex Trim String

Written by Philip

To trim a String in Flex you'll need to use StringUtil.trim , this allows you to basically take the spaces off the end of a string.

Remember you'll need to import mx.utils.StringUtil; so your code should look like as follows.


2
3
4
var stringWithSpacesOnEnd:String = "hello      ";
stringWithSpacesOnEnd = StringUtil.trim(stringWithSpacesOnEnd);
//stringWithSpacesOnEnd will now not be "hello " but "hello"
//As we've just trimed the string.
If your looking for a nice StringUtil class that you can use try the AS3 String Utils class on gskinner.com at