Xray's Log class does this by throwing an intentional error and then
grabbing the stack (of course, this only works if you're using the debug
player) - is this what you're after?

public function Log(p_message:String, p_dump:Object, p_level:Number,
...rest)
       {
           var err:LogError;
           var nullArray:Array;
           try
           {
               nullArray.push("bogus");
           }
           catch(e:Error)
           {
               err = new LogError("log");
           }
           finally
           {
               if(err.hasOwnProperty("getStackTrace"))
               {
                   var str:String = err.getStackTrace();
                   //Debug.trace(err.getStackTrace());
                   setCaller(resolveCaller(str));
               }else
               {
                   setCaller("");
               }
               setMessage(p_message);
               setDump(p_dump);
               setLevel(p_level);
               setClassPackage(p_dump);
           }

       }

On 2/5/07, Jason Boyd <[EMAIL PROTECTED]> wrote:

I think I know the answer, but...

Is there any way to get a stack trace programmatically? I've got a
simple assert function, which terminates script execution on fail, and
it would be sooo helpful to be able to print a stack trace, instead of
having to *tell* the assert function where it is being called from
every time I use it.

A related question: why not? Clearly this info exists at runtime. The
debugger displays it, for instance.

For that matter, I find it rather annoying that you can get a
reference to the calling function via the arguments property, but you
still can't identify which function this is. Am I missing anything
there?

Oh and I'm using AS 2.0 for now. I'm curious about what 3.0 offers for
better error/exception handling, but am not ready to go that route
yet. I suppose I ought to set up ASUnit, but that looks like it might
eat up some time.
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com




--
[  JPG  ]
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to