Test if class method exists in Action Script


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

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.


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.