Return true if we succeeded.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4462 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Ray Greenwell
2006-11-27 22:06:08 +00:00
parent a559b48f38
commit 616f18546c
+7 -4
View File
@@ -8,15 +8,17 @@ public class NetUtil
/** /**
* Convenience method to load a web page in the browser window without * Convenience method to load a web page in the browser window without
* having to worry about SecurityErrors in various conditions. * having to worry about SecurityErrors in various conditions.
*
* @return true if the url was unable to be loaded.
*/ */
public static function navigateToURL ( public static function navigateToURL (
url :String, preferSameWindowOrTab :Boolean = true) :void url :String, preferSameWindowOrTab :Boolean = true) :Boolean
{ {
var ureq :URLRequest = new URLRequest(url); var ureq :URLRequest = new URLRequest(url);
if (preferSameWindowOrTab) { if (preferSameWindowOrTab) {
try { try {
flash.net.navigateToURL(ureq, "_self"); flash.net.navigateToURL(ureq, "_self");
return; return true;
} catch (err :SecurityError) { } catch (err :SecurityError) {
// ignore; fall back to using a blank window, below... // ignore; fall back to using a blank window, below...
} }
@@ -25,12 +27,13 @@ public class NetUtil
// open in a blank window // open in a blank window
try { try {
flash.net.navigateToURL(ureq); flash.net.navigateToURL(ureq);
return true;
} catch (err :SecurityError) { } catch (err :SecurityError) {
Log.getLog(NetUtil).warning( Log.getLog(NetUtil).warning(
"Unable to navigate to URL [e=" + err + "]."); "Unable to navigate to URL [e=" + err + "].");
} }
return false; // failure!
} }
} }
} }