jump to navigation

Quick and easy GetURL class September 18, 2010

Posted by Tournas Dimitrios in Actionscript.

Here is a quick basic url loader for quickly adding links to buttons and movie clips:

// Usage:
// new GetURL("url", "target");

package com.your_domain{

import flash.net.*;

public class GetURL{

private var request:URLRequest;

public function GetURL(url:String, target = '_self'){

request = new URLRequest(url);
navigateToURL(request, target);


It’s just a bare bones script that works like the old getURL method from actionscript 2.
It defaults to opening the url in a blank page, but you can change this by modifying the 2nd parameter.

import com.your_domain.GetURL;

// you can add it right to an event listener for a button or movieclip

yourButton.addEventListener(MouseEvent.CLICK, function(){ new GetURL("your_url.html", "_self")});

// or by itself
new GetURL("your_url.html");

I like using this because it makes the code a lot cleaner and easier to read when you have a bunch of links to deal with. Enjoy!



No comments yet — be the first.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s