Posted by ejot on Mon 7 Jul 11:19 (modification of post by ejot view diff)
report abuse | download | new post
- package
- {
- public class InterestingClass
- {
- protected static function processStacktrace():Object {
- var inspected:Object = new Object();
- var inspectionPattern:RegExp = new RegExp(".*at .*\\/(.*)\\(\\)\\[.*\\/(.*)\\..*\\]");
- var stacktrace:String = new Error().getStackTrace();
- var called:String = stacktrace.split("\n")[2];
- var calling:String = stacktrace.split("\n")[3];
- inspected["called"] = {"cls":called.match(inspectionPattern)[2], "method":called.match(inspectionPattern)[1]};
- inspected["calling"] = {"cls":calling.match(inspectionPattern)[2], "method":calling.match(inspectionPattern)[1]};
- return inspected;
- }
- protected function doOutput(inspected:Object):void {
- trace("I am in", inspected.called.method, "of", inspected.called.cls, "and was called from", inspected.calling.method, "of", inspected.calling.cls);
- }
- public function method1():String {
- var inspected:Object = processStacktrace();
- doOutput(inspected);
- return "I am method1";
- }
- public function method2(value:String):String {
- var inspected:Object = processStacktrace();
- doOutput(inspected);
- return "You told me: " + value;
- }
- }
- }
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.