code_junkie

How do I get the alias string of a class in AS3?

Nov 13th, 2011
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. var alias:String = 'models.User';
  2. registerClassAlias(alias, models.User);
  3.  
  4. // If I have the alias, then
  5. // I can get the class like this:
  6. var klass:Class = flash.net.getClassByAlias(alias);
  7.  
  8. // How do I do the reverse
  9. // (get the alias from the class)?
  10. //
  11. // I want to do this, but I can't find a
  12. // 'getAliasByClass' function.
  13. alias = getAliasByClass(klass);
  14.  
  15. alias = flash.utils.getQualifiedClassName( klass );
  16. // should return: "models::User"
  17.  
  18. override protected function encodeComplex(o:Object, b:IBinary, context:IContext=null):void
  19. {
  20. var desc:XML = describeType(o);
  21. var classAlias:String = desc.@alias;
  22. //...
  23. }
Add Comment
Please, Sign In to add comment