Added a safe navigateToURL method for sending the browser to some page.

If the user embeds the flash client on their own page, if someone then
clicks something to visit a msoy page, we will be unable to load that
page in that same tab/window. Instead, we'll be forced by flash security
restrictions to open in a blank window.
Allow for either method, falling back to a blank window if the other
method fails.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4289 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2006-07-25 02:10:20 +00:00
parent 5b83ee58a0
commit 4d6166dc12
+36
View File
@@ -0,0 +1,36 @@
package com.threerings.util {
import flash.net.URLRequest;
//import flash.net.navigateToURL; // function import
public class NetUtil
{
/**
* Convenience method to load a web page in the browser window without
* having to worry about SecurityErrors in various conditions.
*/
public static function navigateToURL (
url :String, newWindow :Boolean = false) :void
{
var ureq :URLRequest = new URLRequest(url);
if (!newWindow) {
try {
flash.net.navigateToURL(ureq, "_self");
return;
} catch (err :SecurityError) {
// ignore; fall back to using a blank window, below...
}
}
// open in a blank window
try {
flash.net.navigateToURL(ureq);
} catch (err :SecurityError) {
Log.getLog(NetUtil).warning(
"Unable to navigate to URL [e=" + err + "].");
}
}
}
}