`
seya
  • 浏览: 360567 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论

Reflection mechanism in as

阅读更多

reflection method in actionscript:

//refelction method
  protected function getDisplayObjectInstance(skin:Object):DisplayObject{
   var classDef:Object;
   if(skin is Class){
    return new skin() as DisplayObject;
   }else if(skin is DisplayObject){
    (skin as DisplayObject).x = 0;
    (skin as DisplayObject).y = 0;
    return skin as DisplayObject;
   }
   try{
    classDef = getDefinitionByName(skin.toString());
   }catch(e:Error){
    try{
     classDef = loaderInfo.applicationDomain.getDefinition(skin.toString()) as Object;
    }catch(e:Error){
     //nothing
    }
   }
   if(classDef == null){
    return null;
   }else{
    return new classDef() as DisplayObject;
   }
   
  } 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics