One of the things that has become something of a pain in AS3 is getURL. It requires two imports and a try catch. I wrote a little class that simplifies it for me so I can save myself from having to write all that code anytime I want to link to an outside page. Here it is:

Download AS3 GetURL

package net.stevensacks.utils
{
    import flash.net.navigateToURL;
    import flash.net.URLRequest;

    public class Web
    {
        public static function getURL(url:String, window:String = null):void
        {
            var req:URLRequest = new URLRequest(url);
            trace("getURL", url);
            try
            {
                navigateToURL(req, window);
            }
            catch (e:Error)
            {
                trace("Navigate to URL failed", e.message);
            }
        }
    }
}

Usage:

Web.getURL("someurl.html");

 

52 Responses to AS3 getURL solved

  1. Sam says:

    Hi. How can I make a button with an url/link to open in the same window/page and not in a new tag or window?

    Thanks!

  2. Recently medical researchers concluded that children who these oil supplements excel academically.

    Surveys show that only 23% of adult Americans consume the recommended
    level, and. Seafood is a rich diet for having better skin, boosts up memory and even
    for smarter babies.

    My web site cheapest supplements

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Set your Twitter account name in your settings to use the TwitterBar Section.