Use lastIndexOf to get the file name without extension name : Substr : String Flash / Flex / ActionScript examples


Flash / Flex / ActionScript examples » String » Substr »

 

Use lastIndexOf to get the file name without extension name


 

package{
  import flash.display.Sprite;
  
  public class Main extends Sprite{
    public function Main(){

        var filename:String = "document.jpg";
        var extensionIndex:Number = filename.lastIndexOf'.' );
        
        var extensionless:String = filename.substr0, extensionIndex )
        trace"The filename is " + extensionless );


    }
  }
}

        



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


Flash / Flex / ActionScript examples

 Navioo String
» Substr