flex学习笔记1

1 dynamic change the style on runtime
 
as 代码
 
  1. import mx.styles.StyleManager;  
  2. import mx.events.StyleEvent;  
  3.   
  4. var styleEvent:IEventDispatcher = StyleManager.loadStyleDeclarations( name, true );

the name parameter is a swf file that is compiled by a css file        
 etc:'style1.swf'
2 alert function
as 代码
 
  1. import mx.controls.Alert;   
  2. Alert.show('');   


3 reflection invoke
my class
as 代码
 
  1. package com.firebow  
  2. {  
  3.     import mx.controls.Alert;   
  4.     public class Caller  
  5.     {  
  6.         public function show(str:String="abc",other:String=null):void  
  7.         {  
  8.             Alert.show(str);  
  9.         }  
  10.     }  
  11. }  
invoke method show
as 代码
 
  1. var classReference:Class = flash.utils.getDefinitionByName("com.firebow.Caller") as Class;  
  2.                 var instance:Object=new classReference();  
  3.                 var args:Array=new Array();  
  4.                 args[0]="abc";  
  5.                 args[1]="null";  
  6.                 instance["show"].apply(instance,args);  

you can use the pranaframework,it supply some packages ,include reflection
for example
as 代码
 
  1. var type:Type =Type.forInstance(instance);  
  2.                   
  3. trace(type.name); // outputs "MyClass"  
  4.   
  5. trace(type.fullName); // outputs "com.domain::MyClass"  
  6.   
  7. trace(type.methods);  
  8.   
  9. trace(type.staticConstants);  
  10.   
  11. trace(type.staticVariables);  
  12.   
  13. trace(type.constants);  
  14.   
  15. trace(type.variables);  
  16.   
  17. for(var i:int=0;i
  18. {  
  19.     var m:Method=type.methods[i];  
  20.     trace("method:"+m.name);  
  21.     if(m.name=="show"){  
  22.         m.invoke(instance,"KKK");  
  23.     }  
  24. }  
you can get the framework on sourceforge.net/projects/prana/
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值