How to open an URL from ActionScript 3
Today, I will explain how to open an URL in flash using AS3. Like many other things, this is also done a bit differently from what it used to be in AS2.
To open http://www.stormvideogames.com in AS3, for example, one would use the following code, either in a frame, or assigned to a button (check out the button tutorial in this blog if you need).
var myURLhandler:URLRequest = new URLRequest("http://www.stormvideogames.com");
try {
navigateToURL(myURLhandler, '_blank');
} catch (e:Error) {
trace("Error occurred!");
}
Just replace the URL with the one you intend to use. You may also append a ? to the end of the URL to send variables there via GET, as you would with any URL in HTML. For example, http://www.mega-website.com/index.php?go=1 is also a valid URL.
Hope this is helpful to you!
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment