How to use navigateToUrl to access html files relative to the site root?
I try to make an intro animation inside a website, and when the animation is done or when you push the Skip button, it navigates to开发者_开发问答 the index.html file from the site root.
So I have in my site root the folder Flash, where the intro.swf is, and within the intro.swf I called the navigateToURL(new URLRequest("..\index.html"), "_self");
method. Now it's not working. Can you tell how to define the URL request please?
Thanks.
Have you tried this:
navigateToURL(new URLRequest("../index.html"), "_self");
Is using a backslash just a typo?
You know, I once had a weird scoping issue in Flex. The solution was to force an absolute URL by parsing the loaderInfo.loaderURL manually. A simple version might be:
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( "/" );
}
location of your swf file:
loaderInfo.loaderURL
精彩评论