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);
views:
725answers:
4What would you parse in the describeType() XML to get the [RemoteClass(alias="com.foo.javaClassName")]From this code example it looks like you can get attributes using @. override protected function encodeComplex(o:Object, b:IBinary, context:IContext=null):void { var desc:XML = describeType(o); var classAlias:String = desc.@alias;//...}
Dougnukem
2009-11-09 16:00:55
A:
getQualifiedClassName should do the trick.
alias = flash.utils.getQualifiedClassName( klass );
// should return: "models::User"
You can pass it a class reference, or an instance of the class, either way.
fenomas
2009-01-07 10:58:23
Oh - you mean essentially that you want to query which, if any, alias has been registered to a given class? I don't think you can do that. Even if you could, there could be multiple aliases for a given class, couldn't there? I don't know this definitively though, so I'll leave this as a comment.
fenomas
2009-01-08 23:37:01
A:
As stated above you can call flash.utils.describeType() and use "reflection" on your Actionscript object's class to query attributes, properties, methods of the object.
For example the following code snippet for ObjectCodec.as seems to retrieve the alias attribute by using "@":
override protected function encodeComplex(o:Object, b:IBinary, context:IContext=null):void
{
var desc:XML = describeType(o);
var classAlias:String = desc.@alias;
//...
}
Dougnukem
2009-11-09 16:03:54
A:
I think you should check out SWFExplorer by Didier Brun (http://www.bytearray.org/?p=175). SWFExplorer lets you retrieve all the linked-classes available in an ActionScript 3 SWF.
Greet Sid
Sidney
2010-08-24 13:59:31