Posted By

weavermedia on 10/23/09


Tagged

as3


Versions (?)

Who likes this?

6 people have marked this snippet as a favorite

weavermedia
MacEvelly
Winkyboy
mariasoromenho
TrentSkunk
letmein_xxi


AS3 Converting a String to a Function name


 / Published in: ActionScript 3
 

  1. // you might want to call a function but you have the function name as a string, this is how to do it
  2. // Create new :Function var and give it the string using this[]
  3.  
  4. for(i=0; i<4; i++)
  5. {
  6. var funcName:Function = this["func"+i];
  7. funcName(param1, param2);
  8. }
  9.  
  10. function func0(p1, p2)
  11. {
  12.  
  13. }
  14.  
  15. function func1(p1, p2)
  16. {
  17.  
  18. }
  19.  
  20. function func2(p1, p2)
  21. {
  22.  
  23. }
  24.  
  25. function func3(p1, p2)
  26. {
  27.  
  28. }

Report this snippet  

You need to login to post a comment.