Posted By

jayarjo on 01/12/11


Tagged

class as3 methodexists


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

chus
kure69


Test if class method exists in Action Script


 / Published in: ActionScript 3
 

Just add a method like this in a Class that needs to call methods dynamically, without a prior knowledge of whether they exist or not.

  1. private function methodExists(methodName:String) : Boolean
  2. {
  3. var exists:Boolean;
  4. try {
  5. exists = this[methodName] != null;
  6. } catch (e:Error) {
  7. exists = false;
  8. }
  9. return exists;
  10. }

Report this snippet  

You need to login to post a comment.