Tutorials, extensions, and source files for ActionScript, Flash, and other Adobe products.

 

senocular.com ActionScript Library

TrimWhiteSpace.as

1
2
3
4
5
6
7
8
9
10
11
// requires a String.isWhite() method

// trims white space around text
// can be used to remove white space around formatted text node text
_global.TrimWhiteSpace = function(str){
	if (str == "") return "";
	var beg = 0, end = str.length-1;
	while (str.charAt(beg).isWhite()) beg++;
	while (str.charAt(end).isWhite()) end--;
	return str.slice(beg, end+1);
}