开发者

Remove full path with actionscript

How do I actually remove the full path as in C:\program files\app\filename.jpg so that the only left is filename.jpg?

Substr or Substring can be use 开发者_C百科in this case to remove after detecting the first occurrence \ or / by looping from the string end position.

Is there a better method?


The File class gives you a name property, that should give you what you want. For example:

var f:File = new File("C:\program files\app\filename.jpg");
trace("File name is: " + f.name);

The File class is AIR only. If you are working in the Flash Player, try the FileReference class, which has the same property.

The implementation of this is platform agnostic so it should work correctly on both Mac and PC.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜