
The Problem and solution
Erik Liddell
Erik Liddell is an interactive designer based out of Boston MA. He graduated from The School of The Museum of Fine Arts Boston where he focused in Experimental Film and Multi-Media Design.
View all articles by Erik LiddellWhen your computer calls a file like a PDF to your default browser it does so with a command that looks something like this:
yourBrowser -url "file:///c:your.pdf
When using getUrl(); to say:
getUrl("your.pdf","_blank", "GET");
flash actually posts a command like this:
yourBrowser -url "file:///c|your.pdf
Note the Red. Flash changes the ":" to a "|"
Now for what ever reason, IE automaticly interperets them both as a semi colon or ":" But Firefox seems to interperet the "|" as a new tab.
So what do we do? Well we are going to create our own URL, convert it to a string and replace the "|" with a ":"
The first step of this is to find out the directory our SWF resides in and turn that into a variable.
var swfDir:String = _root._url;
next we find the last slash in that string:
var lastSlash:Number = swfDir.lastIndexOf("/");
then we find the pipe or "|":
var colonSpot:Number = swfDir.indexOf("|");
Now we are going to create and empty string and piece all that stuff together replacing the "|" with a ":".
var myUrl:String;
if(colonSpot>=0){
/*that means if we found a "|" if we didn't the colonSpot value would be -1*/
myUrl = swfDir.substring(0,colonSpot);
/*that makes our Url var = everything BEFORE the "|"*/
myUrl +=":"
/* that ads the ":" */
}else{
myUrl="";
}
myUrl+= swfDir.substring(conolSpot+1, lastSlash+1);
/* now we just added back everything after the | */
ok Now we write our getUrl() with our new variable "myUrl"
AS 2.0
myButton.onRelease = function()
{
var targetUrl:String = myUrl + "yourfile.pdf";
getURL(targetUrl, "_blank");
};
AS 3.0
function newGetUrl(event:MouseEvent):void{
var targetUrl:URLRequest = new URLRequest(myUrl + "myfile.pdf");
navigateToURL(targetUrl, "_blank");
}
myButton.addEventListener(MouseEvent.CLICK, newGetUrl);
That’s it, another bug work around.
Spread The Word
9 Responses to "Addressing the "getURL" FireFox bug - AS 2.0 and AS 3.0" 
|
said this on 22 Nov 2007 5:54:50 AM CST
This is not a firefox bug
I'm pretty sure tha |
|
said this on 24 Nov 2007 4:06:08 AM CST
It is actually a firefox
|
|
said this on 26 Nov 2007 1:48:02 PM CST
actually i think he was r
|
|
said this on 02 Dec 2007 3:55:54 PM CST
I would like to see an ex
|
|
said this on 18 Jan 2008 9:26:07 AM CST
I'd have to agree wit
From <scheme>://< An Luckily Firefox |
|
said this on 27 Jan 2008 11:59:59 AM CST
Im getting the following
Firefox does no |
|
said this on 14 Mar 2008 11:14:06 AM CST
Hi All,
trying to get t s var targetUrl:Strin in the fix you it& ? any thoughts a Jim |
|
said this on 19 Feb 2009 5:49:51 AM CST
mmh...does not work. The
|
|
said this on 11 Oct 2009 6:38:47 AM CST
You saved my day! May ma
|



Author/Admin)