FAME Chronicles #2: TRACE (not trace) in MTASC

One of the nice things about MTASC is it’s TRACE function. Utilizing the -trace compile parameter, you can map the TRACE function written in your ActionScript to a static class method of your choice.

You get an additional 3 parameters passed to your trace:

  1. Full class package path and name with method
  2. File name of the class
  3. line number the TRACE command is at in your class

You can get some really informative and nicely formatted trace messages now. Below is something I whipped up this morning to get it to look cool in Flashout; you can use this with trace too if you don’t use Flashout. Modify the tabs to suit.

static public function coolTrace(str:String,
        var splitClassAndMethod:Array = classNameAndMethod.split(".");
        var classAndMethod:String = splitClassAndMethod[splitClassAndMethod.length - 1];
        var classAndMethodArray:Array = classAndMethod.split("::");
        var theClass:String = classAndMethodArray[0];
        var theMethod:String = classAndMethodArray[1];
        var theString:String = "message: \t" + str + "\n";
        theString += "\t\t\tclass: \t\t" + theClass + "\n";
        theString += "\t\t\tmethod: \t" + theMethod + "\n";
        theString += "\t\t\tfilename: \t" + fileName + "\n";
        theString += "\t\t\tline: \t\t" + lineNumber;

The above, when tested, will give you something alone the lines of this:

Pimp as hell, eh!?

Thanks Kenny for inspiring me to get this to work! Now, if I can just figure out how to make the line # a hyperlink so if you click it, it’ll take you to the line number you clicked on in the correct as file…

13 Replies to “FAME Chronicles #2: TRACE (not trace) in MTASC”

  1. Great Jesterfication. It will help you a lot in your debugging. I’m gona talk to our configuration manager here at work today and see if he can’t help me with some loose ends around the unit testing, auto builds, etc that I was tellin ya bout the other nite that I’m doing. I’ll let ya know, since I think given your current work process it would help you guys out a ton. btw- I saw office space last nite again and I swear that the guy is one and the same.

  2. Rockin’… going to try and setup FAME myself today. Haven’t cracked into the source of eclipse yet, may give a java compadre a shout and see if he has dealt with it before. Will drop you a line if I discover anything useful.

    mmmK, now about those TPS reports, nnnYeah…

  3. Although the ‘FAME’ setup does give you some time saving advantages, I find that due to the extremely buggy autocompletion I spend all the saved time deleting the random keywords and variable types ASDT has added to my code.

    public function myFunc():Void {if
    switch(someVar) {
    case 1:Void


  4. When you compile in MTASC inside eclipse, is there a way to get the ‘error’ in the MTASC window to allow you to click the error line and it navigates to the error in the source code, something I’m used to in JAVA or .NET IDE’s, I just installed FAME today to try it out.

  5. Read my last paragraph in my entry… trying to figure that out myself, hehe!

    Robert Penner sent me an email with this idea:

    I have an idea–try formatting a line of text to look like a compile error,
    a la:

    d:/[path]/MyClass.as(314): type error Unknown variable foo

    With PrimalScript at least, when it parses this format it knows how to
    hyperlink to the file and line number.


  6. What verson of MTASC are you runing? I’m running 1.06 and the trace doesn’t seem to work at all inside eclipse with flashout. If I use Flashout.Info(‘Hello’); I see ‘hello’ in the flashout logs tab, if I use trace(‘hello’); I see nothing.

    I also tried doing a -trace Flashout.coolTrace (added your function to my flashout class) and then in my code I do trace(‘somemessage’) and I again don’t see any trace output… Is the trace supposed to go somewhere else ?

  7. try to use TRACE (uppercase) istead of trace.

    // MTASC adds a TRACE function (uppercased)
    // that can be customized at compile time.

  8. I have to say I’m stumped too in terms of using this function too. Is coolTrace meant to replace Flashout.traceReplacer in the Flashout settings of Eclipse? That doesn’t make sense, because coolTrace calls Flashout.debug which calls TRACE, which would be coolTrace?

    Clearly I’m missing something very simple here – if anyone could clarify exactly how to implement this would be very grateful.


  9. I’m using MTASC 1.10 and my
    *mtasc -trace MyClass.myTrace*
    doesn’t work either. When I manually change trace in code to MyClass.myTrace it works fine

  10. If your version of MTASC is high enough (greater than 0.7, but I’m not sure how much greater), you need to replace TRACE with trace throughout Flashout.as.

    Also, Flashout has deprecated
    and now uses
    trace(Flashout.INFO + ‘Test instance 1’);

Comments are closed.