[Laszlo-dev] Debug warning for getMCRef() in SWF10

P T Withington ptw at laszlosystems.com
Wed Jan 27 07:41:23 PST 2010


This is half a loaf.  We'd really like a way to get an arbitrary Function's name, not just the one who's call chain we happen to be in.  It would be great if we could discover a way to do this, perhaps with the introspection API?  I'm not sure we can build our own table, because I'm not sure that the "function" reference you get in a call frame is comparable to the class method (it is a closure over the method and the context).

On 2010-01-27, at 10:12, Henry Minsky wrote:

> Hey Tucker,
> 
> The link that Raju sent does the following hack to use the Flash stack trace
> output to parse out a function's name in AS3 (when debugging is enabled)
> 
> private function getFunctionName(e:Error):String
> {
> 	var s:String = e.getStackTrace();
> 	var i:int = s.indexOf("at ");
> 	var j:int = s.indexOf("()");
> 	return s.substring(i + 3, j);
> }
> 
> private function getCallingFunctionName(e:Error):String
> {
> 	var s:String = e.getStackTrace();
> 	// trace(s);
> 	var i:int = s.indexOf("at ");
> 	i = s.indexOf("at ", i + 3);
> 	if (i == -1)
> 		return "caller unknown";
> 	var j:int = s.indexOf("()", i + 3);
> 	return s.substring(i + 3, j);
> }
> 
> where the latter two functions are can be used like this:
> 
> private function doSomething():void
> {
> 	trace(getFunctionName(new Error()));
> 	doit();
> }
> 
> 
> private function doit():void
> {
> 	trace(getFunctionName(new Error()));
> 	trace("   called by", getCallingFunctionName(new Error()));
> 
> 
> 
> Could we do something like this in the deprecation method (or some
> more general place in the debugger)
> to print function names more informatively?
> 
> 
> 
> On Wed, Jan 27, 2010 at 4:14 AM, Raju Bitter <rajubitter at googlemail.com>wrote:
> 
>> Max,
>> 
>> what is the reason that the warning to use getDisplayObject() instead of
>> getMCRef() is not displayed correctly in DHTML? In SWF10 runtime I get the
>> warning
>> 
>> INFO #helloView.Function is deprecated. Use the #helloView.Function instead
>> 
>> In SWF8 and DHTML output is correct:
>> INFO %cssview.lzx#32: #helloView.getMCRef is deprecated. Use
>> #helloView.getDisplayObject instead
>> 
>> Looking into the code
>> http://svn.openlaszlo.org/openlaszlo/trunk/WEB-INF/lps/lfc/views/LaszloView.lzsI see that you just dump the function reference in the warning. I guess
>> that's because there's no API to retrieve a function's name in AS3. There is
>> a workaround, though, described here:
>> http://blogs.adobe.com/aharui/2007/10/debugging_tricks.html
>> 
>> For this to work, you need to turn on the -verbose-stacktraces=true
>> compiler option - which I'm not sure is done for OpenLaszlo.
>> 
>> - Raju
>> 
> 
> 
> 
> -- 
> Henry Minsky
> Software Architect
> hminsky at laszlosystems.com




More information about the Laszlo-dev mailing list