Categories
Featured jobs
» More ActionScript, Flash and Flex jobs.
» Advertise a job for free
Our network
Advertisement

 »  Home  »  Tutorials  »  Flash  »  Addressing the "getURL" FireFox bug - AS 2.0 and AS 3.0

Addressing the "getURL" FireFox bug - AS 2.0 and AS 3.0

By Erik Liddell | Published 11/15/2007 | Flash | Rating:
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 Liddell
The Problem and solution

When 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.


How would you rate the quality of this article?
1 2 3 4 5
Poor Excellent

Verification:
Enter the security code shown below:
img


Add comment

Spread The Word / Bookmark this content

Clesto Digg it! Reddit Furl del.icio.us Spurl Yahoo!

Comments
  • Comment #1 (Posted by Rafagd - rafagd at gmail.com)
    Rating
    This is not a firefox bug, it's a feature...

    I'm pretty sure that the standards for the file:// protocol doesn't say anything about | being interpreted as :
     
  • Comment #2 (Posted by Christian - tantanix at gmail.com)
    Rating
    It is actually a firefox bug. http://probertson.com/articles/2006/10/11/geturl-flash-projector-firefox-problem/
     
  • Comment #3 (Posted by john - johnG123 at hotmail.com)
    Rating
    actually i think he was reffering to the bug being in the communication between flash/windows/and firefox, but yes it is a firefox bug!
     
  • Comment #4 (Posted by paul - paulfecht at hotmail.com)
    Rating
    I would like to see an example if possible..maybe you've done that and on further inspection I will figure it out but I got a little confused. Sample file?
     
  • Comment #5 (Posted by Mark - ferreem at yahoo.com)
    Rating
    I'd have to agree with comment one, I would say this is an Adobe bug not a Firefox one.

    From what I can gather the official uri spec calls for:

    <scheme>://<authority><path>?<query>

    And never mentions using a pipe character as a substitute.

    Luckily Firefox is taking the initiative and fixing the problem anyway.
     
  • Comment #6 (Posted by tim - tim at ver-voort.com)
    Rating
    Im getting the following message:
    Firefox does not know how to open. The following protocol (ttp) is not recognized by firefox. The original URL DOES contain http. Any ideas why the script is pulling the 'H' out?
     
  • Comment #7 (Posted by jim - jim.contactme at gmail.com)
    Rating
    Hi All,
    trying to get the getURL bug to work.
    since my file is just one folder deep (siteAssets/jimjohnson_resume.pdf) do I just do this:

    var targetUrl:String = myUrl + "siteAssets/jimjohnson_resume.pdf";

    in the fix you've given?

    it's not working, and I think it's something to do with me trying to getURL to a pdf file, and not a swf/or website.

    ?

    any thoughts appreciated,
    Jim
     
Submit Comment



Search Entire Site
Add to Google
Advertisements
Article Options
Latest New Articles
Set up a simple IIS Server for Flash
by Peter McBride

Day 1 at FITC Toronto 2008
by Anthony Pace

Simple reflection effect with AS2
by Jean André Mas

ActionScript.org Meets Josh Tynjala (aka dr_zeus)
by ActionScript.org Staff

Rapidly Create Online Flash Movies to Help Users Market, Sell and Support Software and Hardware
by Sabrina F

mailing list
Enter your email address:
mailing list
Subscribe Unsubscribe
© 2000-2007 actionscript.org! All Rights Reserved.
Read our Privacy Statement and Terms of Use...
Our dedicated server is hosted and managed by WebScorpion Webhosting.