AS3: Extract filename without the extension


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



Copy this code and paste it in your HTML
  1. package{
  2. import flash.display.Sprite;
  3.  
  4. public class Main extends Sprite{
  5. public function Main(){
  6.  
  7. var filename:String = "document.jpg";
  8. var extensionIndex:Number = filename.lastIndexOf( '.' );
  9.  
  10. var extensionless:String = filename.substr( 0, extensionIndex );
  11. trace( "The filename is " + extensionless );
  12.  
  13.  
  14. }
  15. }
  16. }

URL: http://www.java2s.com/Code/Flash-Flex-ActionScript/String/UselastIndexOftogetthefilenamewithoutextensionname.htm

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.