static class name from constructor
forked from static class from constructor (diff: 17)
ActionScript3 source code
/**
* Copyright pleclech ( http://wonderfl.net/user/pleclech )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/tmii
*/
// forked from pleclech's static class from constructor
// forked from pleclech's SO object living
package {
import flash.events.Event;
import flash.utils.setTimeout;
import flash.utils.getQualifiedClassName;
import com.bit101.components.TextArea
public class FlashTest extends TextArea {
public static const NAME:String=getQualifiedClassName(prototype.constructor)
public static var foo:String="bar"
private static var bar:String="foo"
public function FlashTest() {
width=400
height=400
setTimeout(doTest, 500)
}
public function doTest():void {
trace("static access to public var via prototype.constructor ==> " + prototype.constructor.foo)
trace("static access to private var via prototype.constructor ==> " + prototype.constructor.bar)
trace("name of the constructor ==> " + getQualifiedClassName(prototype.constructor))
trace("static name : FlashTest.NAME ==> " + FlashTest.NAME)
trace("static name : Foo.NAME ==> " + Foo.NAME)
trace("static name : Bar.NAME (Bar extends Foo) ==> " + Bar.NAME)
}
public function trace(...args):void {
text=text+args.join(", ")+"\n"
}
}
}
import flash.utils.getQualifiedClassName;
class Foo {
public static const NAME:String=getQualifiedClassName(prototype.constructor)
}
class Bar extends Foo {
public static const NAME:String=getQualifiedClassName(prototype.constructor)
}
