首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

AS3.0高级反照

2012-11-18 
AS3.0高级反射Advanced Flash Tactics or AFTs are techniques that come from deep within the Flash Art

AS3.0高级反射
Advanced Flash Tactics or AFTs are techniques that come from deep within the Flash Art Of War, the oldest Flash military treatise in the world. Each AFT is designed to be quickly digested,

 

在flash.utils包中,我们可以用describeType来处理反射。为了使用describeType,你将需要导入它所在包,然后调用describeType并传递任何类的实例做为参数。下面是一个快速入门的例子:

 

import flash.text.TextField;import flash.utils.describeType;        var classAsXML:XML = describeType(new TextField());trace(classAsXML.toXMLString());

输出:

AS3.0高级反照

 

 

var list : XMLList = classAsXML.*;var propMap : Object = new Object();var item : XML;for each (item in list) {        var itemName : String = item.name().toString();        switch(itemName) {                  case "variable":                          propMap[item.@name.toString()] = item.@type.toString();                          break;                  case "accessor":                          var access : String = item.@access;                          if((access == "readwrite") || (access == "writeonly")) {                                   propMap[item.@name.toString()] = item.@type.toString();                           }                          break;          }}// Output the contents of the propMap objectfor (var prop:String in propMap){        trace(prop, "-", propMap[prop]);}

AS3.0高级反照

热点排行