Posted By

dx0ne on 05/31/11


Tagged

as3


Versions (?)

Check if method exist


 / Published in: ActionScript 3
 

URL: http://www.wastedpotential.com/?p=299

  1. var methodExist:Boolean;
  2. try { //FP10 and up:
  3. methodExist = this["unloadAndStop"] != null;
  4. }
  5. catch (e:Error) { //FP9:
  6. methodExist = this["unload"] != null;
  7. }
  8.  
  9. //or
  10.  
  11. public static function functionExists(obj:Object, name:String):Boolean {
  12. if ( obj == null ) return false;
  13. if (obj.hasOwnProperty(name)){
  14. return true;
  15. } else { return false; }
  16. }

Report this snippet  

You need to login to post a comment.