zoukankan      html  css  js  c++  java
  • Utility Functions For AS3 Classes

    /**
    *   Get a class by its fully-qualified name
    *   @param className Fully-qualified name of the class
    *   @return The class with the given name or null if none exists
    *   @author Jackson Dunstan
    */
    public static function getClassByName(className:String): Class
    {
        try
        {
            return Class(getDefinitionByName(className));
        }
        catch (refErr:ReferenceError)
        {
            return null;
        }
        catch (typeErr:TypeError)
        {
            return null;
        }
     
        return null;
    }
    
    /**
    *   Get the class of an object
    *   @param obj Object to get the class of
    *   @return The class of the given object or null if the class cannot be
    *           determined
    *   @author Jackson Dunstan
    */
    public static function getClass(obj:Object): Class
    {
        if (obj == null)
        {
            return null;
        }
        try
        {
            var className:String = getQualifiedClassName(obj);
            var ret:Class = Class(getDefinitionByName(className));
            if (ret == null && obj is DisplayObject)
            {
                ret = getDisplayObjectClass(DisplayObject(obj));
            }
            return ret;
        }
        catch (refErr:ReferenceError)
        {
            return null;
        }
        catch (typeErr:TypeError)
        {
            return null;
        }
     
        return null;
    }
     
    /**
    *   Get the class of a display object
    *   @param obj Object to get the class of
    *   @return The class of the given object or null if the class cannot be
    *           determined
    *   @author Jackson Dunstan
    */
    public static function getDisplayObjectClass(obj:DisplayObject): Class
    {
        try
        {
            return Class(obj.loaderInfo.applicationDomain.getDefinition(getQualifiedClassName(obj)));
        }
        catch (refErr:ReferenceError)
        {
            return null;
        }
        catch (typeErr:TypeError)
        {
            return null;
        }
     
        return null;
    }
    
  • 相关阅读:
    ios 应用剖析
    nyist 737 相邻石子合并问题
    砝码称重 2
    HDU4614【线段树。】
    Spark安装
    广度优先搜索
    MongoDB 操作手冊CRUD 更新 update
    HiWorkV1.3版震撼公布,今日起正式公开測试!
    织梦调用父级栏目链接和名称
    使用Blender批量导出/转换模型
  • 原文地址:https://www.cnblogs.com/ywxgod/p/1690879.html
Copyright © 2011-2022 走看看