views:

2936

answers:

6

Intro to the problem -
With AS3 I want that when people clicks an email address, it opens their email program. Therefore I do this:

mc.addEventListener(MouseEvent.CLICK, sendEmail);

function sendEmail(e:MouseEvent):void{<br />
     navigateToURL(new URLRequest("mailto:[email protected]"));<br />
}

The problem: Every time a user clicks the movie clip, it opens their email program. However, the browser is opening a new window as well. How can I avoid the browser from opening the new window when clicking the movie clip that has the email address?

A: 

try

navigateToUrl(urlRequest, "_self");

from API

CookieOfFortune
Yep this did it. Thanks
Ole Media
A: 

The mailprogram is opening because you gave a mail ID as URL. I think your intention is sending mail when a user click on the link right?

And to open in same window use what CookieOfFortune is saying. In

navigateToUrl(urlRequest, "_self");

the second part, _self, is setting the target window as self. If you want to open in new window you have to use navigateToUrl(urlRequest, "_blank");

Dubaigenius
+2  A: 

There is a very easy answer to this. Navigate to URL will open a new browser window or do it in itself depending on how specified, if no window is open it opens one regardless. Use sendToURL instead of navigateToURL, I just tested and it works fine.

sendToURL(new URLRequest("mailto:[email protected]"));

sendToURL is also a function in the flash.net package

Cheers, Brian Hodge
blog.hodgedev.com

Brian Hodge
A: 

I'm having a similar problem. Could You guys help, please? Here's the code:

email_bt.addEventListener(MouseEvent.CLICK, sendMail);
function sendMail(e:MouseEvent):void {
    sendToURL(new URLRequest("mailto:[email protected]"));
}

Where do I go wrong? I mean I get no error messages or anything, but my default mail app won't upon up, whenever the button is clicked.

Thanks in advance

O.S.
Better post this as a new question ("Ask Question" button in the top right of the page). More people will see it that way.
sth
A: 

Brian Hodge is correct!

Sammurai
Upvote him instead of adding an answer then.
poke
A: 

Maybe it's because of you are testing this locally?

Andrew