02Sep Static Initializers… Flash has ‘em
378 views
While blog stumbling this morning, I have discovered that AS3 allows static initializers (or sometimes called static constructors). This allows a chunk of code to execute when the class is first referenced in a static fashion (for example while grabbing a static property). Below is a quick example of the syntax needed:
package {
public class Test {
{trace("Static Initializer");}
}
}
public class Test {
{trace("Static Initializer");}
}
}
I can’t think of anything particularly useful for this method except for very unique cases where frameworks or singletons need immediate initialization functionality sometime before their instance constructor is run…
Blog stumbles:
New ActionScript 3 Singleton Method
43 Hot Flex and ActionScript 3.0 APIs, tips and tools for Autumn 2008
Auto-Generated Related Posts:
