【发布时间】:2010-10-26 13:42:41
【问题描述】:
我尝试在网站内制作介绍动画,当动画完成或按下“跳过”按钮时,它会从网站根目录导航到 index.html 文件。
所以我在我的站点根目录中有文件夹 Flash,intro.swf 所在的位置,在 intro.swf 中我调用了navigateToURL(new URLRequest("..\index.html"), "_self"); 方法。现在它不工作了。请问如何定义URL请求?
谢谢。
【问题讨论】:
我尝试在网站内制作介绍动画,当动画完成或按下“跳过”按钮时,它会从网站根目录导航到 index.html 文件。
所以我在我的站点根目录中有文件夹 Flash,intro.swf 所在的位置,在 intro.swf 中我调用了navigateToURL(new URLRequest("..\index.html"), "_self"); 方法。现在它不工作了。请问如何定义URL请求?
谢谢。
【问题讨论】:
你试过了吗:
navigateToURL(new URLRequest("../index.html"), "_self");
使用反斜杠只是一个错字吗?
【讨论】:
您知道,我曾经在 Flex 中遇到过一个奇怪的范围问题。解决方案是通过手动解析 loaderInfo.loaderURL 来强制使用绝对 URL。一个简单的版本可能是:
function getAbsoluteURL( pathFromSwf:String, swfURL:String ):String
{
// if pathFromSwf is already a URL, then just return that.
if( pathFromSwf.match( /^(http.{3}[^\/]{5,})\/(.*)$/ ) ) return pathFromSwf;
// this may need to be customized based on your extension/server settings.
var basePath:Array = swfURL.substr( 0, swfURL.indexOf( ".swf" ) ).split( "/" );
basePath.pop(); // clear out the swf's name.
var altPath:Array = pathFromSwf.split( "/" );
for( var i:int = 0; i < altPath.length; i++ )
{
// ".." subtracts from the path/
if( altPath[ i ] == ".." ) basePath.pop();
// otherwise append
else basePath.push( altPath[ i ] );
}
return basePath.join( "/" );
}
【讨论】:
您的 swf 文件的位置:
loaderInfo.loaderURL
【讨论】: