1180: Call to a possibly undefined method getURL. Actionscript 3
Hello all actionscripters — you can’t use getURL anymore in ActionScript 3. It was removed in the move from AS2 to AS3.
Below is how you should do it instead:
var request:URLRequest = new URLRequest("/");
try {
navigateToURL(request, '_blank');
} catch (e:Error) {
trace("Error occurred!");
}
In AS3, navigateToURL() replaces the old getURL() function. You need to create a URLRequest object first and pass it in. The second parameter is the target window — '_blank' opens a new tab, '_self' navigates the current page.
Wrapping it in a try/catch is good practice since the browser can block pop-ups, which throws a security error. This is especially common when the navigateToURL call isn’t triggered directly by a user click event.
Don’t forget to import: import flash.net.URLRequest; and import flash.net.navigateToURL;