Hi, just a little handy AS3 snippet I thought I’d share. It simulates the string.format from dotnet in a trace statement. I decided to name it tracef like printf in c (f = format)
tracef("my location = ({0}, {1}), my name is {2}", x, y, name)
Here’s the debug function:
private function tracef(msg:String, ...arguments):void { for( var i:uint = 0; i < arguments.length; ++i ) { msg = msg.split("{"+i+"}").join(arguments[i]); } trace( msg ); }
Btw, msg’s are bad for you, at least in your food, but that’s a different story.