Flash获取当前文件名

As3版本:
[source]//当前文件的完整路径
var fileUrl:String = this.loaderInfo.url;
//查找路径的最后一个”/”
var flag:int = fileUrl.lastIndexOf(“/”);
//截取文件名
var fileName:String = fileUrl.substr(flag + 1, fileUrl.length);
//输出
trace(fileName);
if (ExternalInterface.available) {
ExternalInterface.call(‘alert’,swfurl);
}

[/source]

As2版本:
[source]var swf1 = _root._url.lastIndexOf(“/”)+1;
var swfurl = _root._url.substr(swf1, _root._url.length);
if (ExternalInterface.available) {
ExternalInterface.call(‘alert’,swfurl);
}
trace(swfurl);[/source]

发表评论?

0 条评论。

发表评论


注意 - 你可以用以下 HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>