Notes, figured out how to make a static initializer.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3932 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2006-03-09 22:14:08 +00:00
parent 704fbfaec3
commit 2f2ffdabbe
2 changed files with 28 additions and 14 deletions
+14
View File
@@ -218,3 +218,17 @@ ActionScript
error (grraah!). There is a compiler option "-compiler.warn-no-constructor"
but it generates a flotilla of warnings from standard classes in the flash
library, so it's slightly useless.
***Update: What the heck. I noticed today that DSet has no constructor
and I've never had any trouble instantiating those. Why would not having
a constructor be an error for some classes and not others? Grraahh!
- Static initializers can be emulated:
public class A
{
private static function staticInit () :void
{
// whatever
}
staticInit(); // will be placed inside the real static initializer
}
+14 -14
View File
@@ -19,22 +19,22 @@ public class LogDaddy
*/
public static function getLogger (pkg :String) :ILogger
{
if (_targ == null) {
// goddamn I wish we could just have static initializers
_targ = new TraceTarget();
_targ.filters = ["*"];
_targ.level = LogEventLevel.DEBUG;
mx.logging.Log.addTarget(_targ);
// we could do some stuff here: set up different targets
// with different log levels...
}
return mx.logging.Log.getLogger(pkg);
}
/** The logging target for all packages. Needed only because we
* cannot have static initializers, so we need to know in getLogger
* if we've set up the target yet or not. */
private static var _targ :TraceTarget;
/**
* Our static (class) initializer.
*/
private static function staticInit () :void
{
var targ :TraceTarget = new TraceTarget();
targ.filters = ["*"];
targ.level = LogEventLevel.DEBUG;
mx.logging.Log.addTarget(targ);
// we could do some stuff here: set up different targets
// with different log levels...
}
staticInit(); // call our static initializer
}
}