Skip to main content
New Participant
March 26, 2009
Answered

Getting a button to link to mailto link

  • March 26, 2009
  • 3 replies
  • 2917 views
OK, I've trawled the web, everyone with different ideas on how to call up a mailto link in AS3.
What I'm looking for is this:
I have a box, that is coverted to a button symbol given the name 'mailto'
I have another layer for the actionscript
I have imported 'flash.net.navigateToURL' and 'flash.net.URLRequest'
I know I need to create a function or a variable to link in the already created button.
Do I also need to import the MouseEvents?

I created this FLA to get used to CS4 (i was previously using 8)
Everything works wonderfully, I would just like to know how to use AS3 properly, without having to call defeat and create the FLA again using AS2.
This topic has been closed for replies.
Correct answer lam08
//SET THE MAILTO ADDRESS
var emailLink:String = "mailto:xxxx@xxxxx.com";

//ADD EVENT LISTENER FOR EMAIL LINK
mailtoLink.addEventListener(MouseEvent.MOUSE_DOWN,function():void {
navigateToURL(new URLRequest(emailLink), "_self");}
);

3 replies

New Participant
March 26, 2009
ahh yes the Instance Name. totally passed that one by.
The file has exported with no errors, now all I need is to upload it and see if it works.

Thank you both very much for your help
New Participant
March 26, 2009
Thank you very much..
I'm almost there now.
I come up with an error saying that I have an unidentified property mailtoLink. I'm guessing this would be for the button itself. How would I tell the code that this link will happen when that button is clicked?
Ned Murphy
Braniac
March 26, 2009
mailtoLink would be the instance name of the button, so either name the button that or change it it to agree the button's instance name
lam08Correct answer
Inspiring
March 26, 2009
//SET THE MAILTO ADDRESS
var emailLink:String = "mailto:xxxx@xxxxx.com";

//ADD EVENT LISTENER FOR EMAIL LINK
mailtoLink.addEventListener(MouseEvent.MOUSE_DOWN,function():void {
navigateToURL(new URLRequest(emailLink), "_self");}
);