Reflection in ActionScript 3


/ Published in: ActionScript 3
Save to your folder(s)



Copy this code and paste it in your HTML
  1. var className:String = 'com.firstrowria.SampleClass';
  2.  
  3. var classReference:Class = Class(getDefinitionByName(className));
  4.  
  5.  
  6. var classInstance:Object = new classReference();
  7.  
  8.  
  9. var functionName = 'sampleFunction';
  10. var functionName2 = 'sampleFunctionWithParameter';
  11.  
  12. classInstance[event.functionName]();
  13. classInstance[event.functionName2]('this is my string parameter');

URL: http://www.firstrowria.com/2008/06/as3-reflection-in-actionscript/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.