1 dynamic change the style on runtime
as 代码
- import mx.styles.StyleManager;
- import mx.events.StyleEvent;
-
- var styleEvent:IEventDispatcher = StyleManager.loadStyleDeclarations( name, true );
etc:'style1.swf'
2 alert function
as 代码
- import mx.controls.Alert;
- Alert.show('');
3 reflection invoke
my class
as 代码
- package com.firebow
- {
- import mx.controls.Alert;
- public class Caller
- {
- public function show(str:String="abc",other:String=null):void
- {
- Alert.show(str);
- }
- }
- }
invoke method show
as 代码
- var classReference:Class = flash.utils.getDefinitionByName("com.firebow.Caller") as Class;
- var instance:Object=new classReference();
- var args:Array=new Array();
- args[0]="abc";
- args[1]="null";
- instance["show"].apply(instance,args);
you can use the pranaframework,it supply some packages ,include reflection
for example
as 代码
- var type:Type =Type.forInstance(instance);
-
- trace(type.name);
-
- trace(type.fullName);
-
- trace(type.methods);
-
- trace(type.staticConstants);
-
- trace(type.staticVariables);
-
- trace(type.constants);
-
- trace(type.variables);
-
- for(var i:int=0;i
- {
- var m:Method=type.methods[i];
- trace("method:"+m.name);
- if(m.name=="show"){
- m.invoke(instance,"KKK");
- }
- }
you can get the framework on
sourceforge.net/projects/prana/