Links in AS3 – getURL / URLRequest

I know what you’re thinking – why use getURL like in AS2 when you can write all this for a simple link:

import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.net.navigateToURL;

var emailAddress:String = "noone34343@nowhere453646.com";
submitIdeaBtn.addEventListener(MouseEvent.CLICK, submitBtnIdeaHandler);
function submitBtnIdeaHandler(event:MouseEvent):void
{
  var mailString:String = "mailto:" + emailAddress + "?subject=Idea&body=This idea will help " + field0.text + " and is this: " + field1.text;
  var url:String = mailString;
  var request:URLRequest = new URLRequest(url);
  try {
    navigateToURL(request, '_blank');
  } catch (e:Error) {
    trace("Error occurred!");
  }
}

Source:
http://scriptplayground.com/tutorials/as/getURL-in-Actionscript-3/

Tech Reference:

Leave a Reply

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

Proudly powered by WordPress | Theme: Baskerville 2 by Anders Noren.

Up ↑