Check if method exist


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



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

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.