How to get a string of class aliases in AS3?

var alias:String = 'models.User'; registerClassAlias(alias, models.User); // If I have the alias, then // I can get the class like this: var klass:Class = flash.net.getClassByAlias(alias); // How do I do the reverse // (get the alias from the class)? // // I want to do this, but I can't find a // 'getAliasByClass' function. alias = getAliasByClass(klass); 
+4
source share
3 answers
+1
source

getQualifiedClassName should do the trick.

 alias = flash.utils.getQualifiedClassName( klass ); // should return: "models::User" 

You can pass it a reference to the class or class instance in any case.

+1
source

As stated above, you can call flash.utils.describeType () and use the "reflection" in your ActionScript object class to request the attributes, properties, methods of the object.

For example, the following code snippet for ObjectCodec.as seems to retrieve the alias attribute using "@":

 override protected function encodeComplex(o:Object, b:IBinary, context:IContext=null):void { var desc:XML = describeType(o); var classAlias:String = desc.@alias ; //... } 
0
source

All Articles