« Return to Thread: NEED HELP with mtasc trace option

Re: NEED HELP with mtasc trace option

by Joeri van Oostveen :: Rate this Message:

Reply to Author | View in Thread

I'm using Firebug too for debugging, with a custom trace like this one (stripped a little because there was some unused code in when I tried to do some more with it, but never finished it).
You can get a lot more out of it, but I have never spent more time in it and mapped all console.error etc.
It does not include a variable dump or give a recursive trace of object etc, but it certainly can be useful.

I use ant to build the projects, therein the following piece is added for using a custom trace (The class file is stored in the top package, not nested in directories). The second 'CustomTrace' after CustomTrace.trace is used to include the class in the swf.

<arg value="-trace"/>
<arg value="CustomTrace.trace"/>
<arg value="CustomTrace"/>


import flash.external.ExternalInterface;

class CustomTrace
{
public function CustomTrace()
{
}

public static function trace(message:String, classMethod:String, file:String, line:Number):Void

{
var d:Date = new Date();
var timestamp:String = "[" + formatDate(d.getHours().toString(), 2) + ":" + formatDate(d.getMinutes().toString(), 2) + ":" + formatDate(d.getSeconds().toString(), 2) + "]";
var trace_message:String = "";
trace_message += timestamp + ": ";
trace_message += "" + classMethod + " ";
trace_message += "" + message + "";
ExternalInterface.call("console.log", trace_message);
}
private static function formatDate(dateString:String, len:Number):Object

{
dateString = "000000" + dateString;
dateString = dateString.substr(dateString.length - len, len);

return dateString;

}
}


Hope this helps.

- Joeri

On Feb 4, 2008 1:26 PM, Selene Platt <selene@...> wrote:

Hello,

I am using mtasc as an actionscript 2.0 compiler and want to add the -trace
option.  However, I'm not sure how to implement my own trace function.  The
example given on the web ( http://www.mtasc.org/#trace ) doesn't exactly
show where MyClass.myTrace() is defined and what it looks like.  Could
someone provide an example assuming I have the following already in place:

class myClass
{
   public static function main(root) {

   (in here, I access a flash shared object:
    myFlashObject = SharedObject.getLocal(root.FO_VAL);
   ... And so forth )

   ultimately calling the javascript callback function:
   getURL("javascript:setValue('" + ret_val + "')");
}

There are 3 input parameters on the SWF call, which I refer to as root.a,
root.b, and root.c based on precompiled #DEFINE's.

I want to trace the value of the params and ret_val.  Should I define a
separate class for the trace function?  What code should it contain that
will actually print out the values I need?

Also, if I am debugging in Firebug (in Firefox), for example, where should I
expect these trace messages to come out -- in the browser window, in the
firebug console, or where?

I am really under the gun here...my swf was working and suddenly stopped
during a major test cycle that depends on my code.  So I would greatly
appreciate a fast response if someone has some info. Thanks very much,

Selene


--
MTASC : no more coffee break while compiling


--
MTASC : no more coffee break while compiling

 « Return to Thread: NEED HELP with mtasc trace option