If you have ever tried to do a simple getURL() command in Flash from an .exe projector you’ll notice that it fails when Firefox is your default browser.
Following is the solution to the problem in both AS 2.0 and AS 3.0
Here’s the code for the fix in AS 2.0:
// code on a keyframe on the main timeline
var swfUrl:String = _root._url;
var lastSlashIndex:Number = swfUrl.lastIndexOf("/");
var pipeIndex:Number = swfUrl.indexOf("|");
var baseUrl:String;
if (pipeIndex >= 0)
{
baseUrl = swfUrl.substring(0, pipeIndex);
baseUrl += ":";
}
else
{
baseUrl = "";
}
baseUrl += swfUrl.substring(pipeIndex + 1, lastSlashIndex + 1);
myButton.onRelease = function()
{
var targetUrl:String = baseUrl + "test.html";
getURL(targetUrl, "_blank");
};
Here’s the code for the fix in AS 3.0:
// code on a keyframe on the main timeline
import flash.events.MouseEvent;
import flash.net.*;
output_txt.text = this.loaderInfo.url;
var swfUrl:String = this.root.loaderInfo.url;
var lastSlashIndex:Number = swfUrl.lastIndexOf("/");
var pipeIndex:Number = swfUrl.indexOf("|");
var baseUrl:String;
if (pipeIndex >= 0)
{
baseUrl = swfUrl.substring(0, pipeIndex);
baseUrl += ":";
}
else
{
baseUrl = "";
}
baseUrl += swfUrl.substring(pipeIndex + 1, lastSlashIndex + 1);
function gotoTestHtml(event:MouseEvent):void
{
var targetUrl:URLRequest = new URLRequest(baseUrl + "test.html");
navigateToURL(targetUrl, "_blank");
}
myButton.addEventListener(MouseEvent.CLICK, gotoTestHtml);
Here is a link to the original article where I found this with the full explanation and fix.