View Full Version : Finding a function's caller
HotN
March 31st, 2009, 11:59 AM
If I've got a public function in a class that I know is being called from an object outside the class, is there any way to access either a reference to the calling object or at least the calling object's type from within that function without passing the caller through as a parameter?
Krilnon
March 31st, 2009, 12:04 PM
Nope, arguments.caller was removed from AS3.
I guess you could save it in a global variable or something silly like that, but that's hardly a solution.
wvxvw
March 31st, 2009, 01:58 PM
In debug player: trace(new Error().getStackTrace()); + a lot of sphisticated string parsing + describeType() etc.
In release player - no.
Oh, and BTW, there's a more convenient way, like this:
http://livedocs.adobe.com/flex/3/langref/flash/sampler/StackFrame.html
Though, again, for debugger only.
HotN
March 31st, 2009, 02:51 PM
Following the stack trace in the debugger got me where I needed to go, thanks!
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.