Flash: Get filename from full url


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

Retrieves a filename from a complete url


Copy this code and paste it in your HTML
  1. private static function getFilenameFromUrl(url:String):String
  2. {
  3. var letters:Array= [];
  4. var charPosition:int= url.length;
  5. var currentCharacter:String;
  6.  
  7. while(currentCharacter != '/' && currentCharacter != '\\') {
  8. currentCharacter = url.charAt(charPosition);
  9. letters.push( currentCharacter);
  10. charPosition--;
  11. }
  12. letters = letters.reverse();
  13. letters.shift();
  14. var filename:String = letters.join('');
  15. return filename;
  16. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.