PDA

View Full Version : email link


pnicklin
06-26-2009, 12:56 PM
Hi, this is probably a simple issue, but i'm new to actionscript and am pulling my hair out trying to get this email button working.

I have a simple button in flash 8 which I have labeled "email_btn." I am using actionscript 3.0 and in the actions layer I have this code:



var emailLink:URLRequest = new URLRequest("mailto:myemail@whatevermail.com");

email_btn.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler140);
function mouseDownHandler140(event:MouseEvent):void {
{
navigateToURL("mailto:myemail@whatevermail.com");
}



However it is coming up with this error:

1084: Syntax error: expecting rightbrace before end of program.

Please help.

novasatori
06-26-2009, 01:08 PM
idk, but have you tried removing the { from this line

function mouseDownHandler140(event:MouseEvent):void {

pnicklin
06-26-2009, 01:15 PM
I just removered the }

it now comes up with this error:

1067: Implicit coercion of a value of type String to an unrelated type flash.net:URLRequest.

novasatori
06-26-2009, 02:01 PM
Try this instead:

//SET THE MAILTO ADDRESS
var emailLink:String = "mailto:email@address.com";

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

from http://www.stemkoski.com/using-mailto-in-flash-with-actionscript-30/

OmerHassan
06-26-2009, 02:46 PM
The first argument of navigateToURL() should be a URLRequest object, not a String.

Use this:
navigateToURL(emailLink);

because emailLink is a URLRequest object.

novasatori
06-26-2009, 02:54 PM
Ah, I see it now...that's why his code doesn't work but the code I posted does...couldn't figure it out at first.

pnicklin
06-26-2009, 02:59 PM
That has worked a treat, thank you very much novasatori,

Muchos Appreciated!