Flash AS3 Links Made Easy – AS3 Link Class – Download

Many times when creating banners with multiple clickable areas, it’s a pain to do an event listener for each and a function to navigate to that particular URL.

I needed something faster and created a “dead simple” as3 link class, which allows creating as3 links in 1 line. You can download the class and a demo file by clicking the button below.

[download url=http://docs.moonpixel.com/100718-demo.zip]

To use the class from the demo, upload the moonpixel folder to your default class path (more on as3 classpath here >).

Then you can just use it on Buttons, Movie Clips and other Display Objects like so:

var link = new Link(obj:DisplayObject,lnk:String,trgt:String);

Here’s how the class looks, it’s very simple but makes life easier:

package moonpixel.net
	import flash.display.DisplayObject;
	import flash.events.MouseEvent;
	import flash.net.URLRequest;
	import flash.net.navigateToURL;
	public class Link
		private var link:String = new String();
		private var urlReq:URLRequest;
		private var target:String = new String();
		public function Link(obj:DisplayObject,lnk:String,trgt:String)
			obj.addEventListener(MouseEvent.CLICK, golink);
			link = lnk;
			target = trgt;
		private function golink(e:MouseEvent):void 
			urlReq = new URLRequest(link);
  • Bret88

    How do I use that to open a link in a new window?

    • var link = new Link(name of your button,link url,"_blank");
  • Nice post !! thanks

  • Finally, I located the information I was searching for. I have been doing research on this subject, and for four days I keep finding sites that are supposed to have what I am searching for, only to be disappointed with the lack of what I wanted. I wish I could have found your web-site quicker! I had about 40% of what I needed and your site has that, and the rest of what I need to finish my research. Thank you and keep up the good work!

  • Daylyn

    nice job,thks.