Wow, this is really great. Thanks Ralf.

Scott

-----Original Message-----
From:   [EMAIL PROTECTED] on behalf of Ralf Bokelberg
Sent:   Wed 1/18/2006 7:21 PM
To:     Open Source Flash Mailing List
Cc:     
Subject:        [osflash] hamtasc: stacktrace available

I slightly changed the rb_auto_trace option to include the current scope 
and the arguments. Also i added another option rb_auto_trace_pop, which 
is called, whenever a function is left. This way we are able to produce 
stacktraces now, using the following actionscript class

/**
  * @author ralf bokelberg
  */
class de.bokelberg.debug.AutoTraceStackManager {
       public static var stack:Array = new Array();

       public static function push(
        className:String,
        methodName:String,
        fileName:String,
        lineNumber:Number,
        scope:Object,
        arguments:FunctionArguments):Void
       {
              stack.push(arguments);
       }

       public static function pop(
        className:String,
        methodName:String,
        fileName:String,
        lineNumber:Number):Void
       {
              stack.pop();
       }

       public static function toString():String{
                return stack.join("\n");
       }
}

You also need to add the following parameters to your build script
<arg value="-rb_auto_trace"/>
<arg value="de.bokelberg.debug.AutoTraceStackManager.push"/>
<arg value="-rb_auto_trace_pop"/>
<arg value="de.bokelberg.debug.AutoTraceStackManager.pop"/>
<arg value="de/bokelberg/debug/AutoTraceStackManager" />

Now you can test it in a try/catch for example:


import de.bokelberg.debug.AutoTraceStackManager;

/**
  * @author ralf bokelberg
  */
class test.MainClass {
        
        public static function main( mc:MovieClip):Void{
                var m:MainClass = new MainClass();
                m.test();
        }
        
        public function test():Object{
                try  {
                        throw( new Error("hey"));
                        return null;
                } catch( e:Error){
                         trace(e.toString()
                            + "\n"
                            + AutoTraceStackManager.toString());
                }
        }
}

And if you run it, you should see something like this output
(i partly replaced the path by ... below)

hey
test.MainClass,main,...ss.as,7,[type Function],_level0,
test.MainClass,test,...ss.as,14,[object Object],

Cheers,
Ralf.




_______________________________________________
osflash mailing list
[email protected]
http://osflash.org/mailman/listinfo/osflash_osflash.org



<<winmail.dat>>

_______________________________________________
osflash mailing list
[email protected]
http://osflash.org/mailman/listinfo/osflash_osflash.org

Reply via email to