Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3250760
  • 博文数量: 530
  • 博客积分: 13360
  • 博客等级: 上将
  • 技术积分: 5473
  • 用 户 组: 普通用户
  • 注册时间: 2006-07-13 13:32
文章分类

全部博文(530)

文章存档

2017年(1)

2015年(2)

2013年(24)

2012年(20)

2011年(97)

2010年(240)

2009年(117)

2008年(12)

2007年(8)

2006年(9)

分类: Web开发

2013-03-27 15:47:53

转载:http://blog.csdn.net/dengxingbo/article/details/5775236

1.将字符串转换为类

       var classToConstruct:Class=getDefinitionByName("com.sig.ClassA") as Class;
       var s:ClassA =new classToConstruct();

2.将字符串转换为函数


  1.         public var actionRef:String = "getit"
  2.                 
  3.         protected function button1_clickHandler(event:MouseEvent):void
  4.         {
  5.              if (this.hasOwnProperty(actionRef))
  6.                  this[actionRef]();
  7.                 
  8.         }
  9.             
  10.         public function getit():void
  11.         {
  12.             Alert.show("i am click");
  13.         }

3.将字符串转换成变量


  1.         var object:Object = new Object();
  2.         var value:int=10;
  3.                 
  4.         for(var i:int = 1;i<3;i++){
  5.              object["x"+i] =value;
  6.              value++;
  7.         }
  8.                 
  9.         Alert.show(object.x1);
  10.         Alert.show(object.x2);
调用本类的属性,可使用 this[variable_name]


参考文献

阅读(1051) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~