AS3 trim()

Posted in ActionScript 3
2009-10-27 20:55:22 +0000 UTC

I found this snippet while revisiting some old code, and thought it might help someone else. It's trim() for AS3, and it should work in Flash or Flex.

function trim( s:String ):String
	return s.replace( /^([\\s|\\t|\\n]+)?(.*)([\\s|\\t|\\n]+)?$/gm, "$2" );

BulkLoader resumeAllLoaders

Posted in ActionScript 3
2009-06-13 03:41:56 +0000 UTC

During a recent project, I had an issue with BulkLoader. I wanted to pause all of the loaders running, then resume them later. Pausing them was easy, as BulkLoader has a static method 'pauseAllLoaders'. But resuming them was another issue. I could resume individual items with resume(), or a whole instance with resumeAll(), but there was no method for resuming all instances.

Multiline Strings in AS3

Posted in ActionScript 3
2009-03-28 19:30:51 +0000 UTC

If you've ever needed to make multiline strings in AS3, you may have found yourself doing something awkward like this:

var s:String = "This is a multiline string\\n";
s += "It has multiple lines.\\n";
s += "Too bad the implementation is weird.";