1 /* 2 Copyright aswing.org, see the LICENCE.txt. 3 */ 4 5 /** 6 * Reflection Utils. 7 * @author iiley 8 */ 9 class org.aswing.utils.Reflection { 10 11 /** 12 * Return the class object by the specified class name. 13 * <p>Then you can use this way to create a new instance of this class: 14 * <pre> 15 * var classConstructor:Function = Reflection.getClass("your_class_name"); 16 * var instance:YourClass = YourClass(new classObj()); 17 * </pre> 18 * Or call it's static method from this way: 19 * <pre> 20 * var classConstructor:Function = Reflection.getClass("your_class_name"); 21 * classConstructor.itsStaticMethod(args); 22 * </pre> 23 * 24 * @param fullname the class's full name include package. For example "org.aswing.Component" 25 * @return the class object of the name 26 */ 27 public static function getClass(fullname:String):Function{ 28 var parts:Array = fullname.split("."); 29 var classObj:Object = _global; 30 for(var i:Number=0; i<parts.length; i++){ 31 classObj = classObj[parts[i]]; 32 } 33 return Function(classObj); 34 } 35 36 } 37