2
votes

is there something like basename function in Flex? I cannot find it :S

2
What do you expect that function to do? - poke
en.wikipedia.org/wiki/Basename I know I can easily implement this function using the functions from String class but I'm curious if such a function exists in Flex/AS 3.0. - Jacek Francuz

2 Answers

3
votes

As far as I remember there isn't such function in Flex, however you can always create your own "native" version of it.

package {
    public function basename(path:String):String {
        var index:Number = path.lastIndexOf('/');
        if (index != -1) {
            return path.substr(index + 1);
        }
        return path;
    }
}

Usage:

trace(basename("/path/to/some/file.extension")); //file.extension
1
votes

download as3Corelib and look into the var _authority in the URI class