AS3 Get a File Extension from a URL or Filename


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



Copy this code and paste it in your HTML
  1. function getExtension($url:String):String
  2. {
  3. var extension:String = $url.substring($url.lastIndexOf(".")+1, $url.length);
  4. return extension;
  5. }
  6.  
  7. trace(getExtension("my_filename.jpg"));
  8. // OUTPUT: jpg

Report this snippet


Comments


You need to login to view comments.