views:

210

answers:

4

Hi,

I read somewhere a utils to show the class + line nbr of the function who called a trace("foo") which is very handy once you start getting a lot of debug output.

Any hints on where to find it ? it was open source, maybe shown at a flex event.

trace("my debug");

> mydebug :34 bla.as3 ..

Thanks,

Greg

A: 

I haven't seen a package like that before but you might get lucky searching google's codesearch with a well devised regex.

Sugerman
A: 

I think you're referring to haXe (http://haxe.org), which is an open source programming language very similar to ActionScript.

They don't have a browser-accesible repository but you can download the sources following the instructions here http://haxe.org/download.

I did manage to find something on Google Code Search:

mrm
A: 

Have you tried using the MonsterDebugger yet ? It's quite comprehensive, easy to install, and showed a lot more than just the trace statements - see the features pages on the site for an overview.

I've tried it, but it was too rich for my taste and I went back to simple trace statements - my programs aren't that complex yet !

Alex Boschmans
+2  A: 

Here is a quick&dirty solution:

 private function mytrace(s:String):void {
  try {
   throw new Error();
  } catch (e:Error) {
   var arr:Array = e.getStackTrace().split("\n", 3);
   trace(arr[2] + " " + s);
  }
 }

For mytrace("xyz") you will get:

at Main/init() xyz

or if you compile with "-debug=true":

at Main/init()[C:\home\myproject\Main.mxml:120] xyz
tst