flashactionscript-3flash-cs4

AS3 - mailto is opening a new browser window


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:name@domainname.com"));<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?


Solution

  • 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 sendToURLinstead of navigateToURL, I just tested and it works fine.

    sendToURL(new URLRequest("mailto:name@example.com"));
    

    sendToURL is also a function in the flash.net package

    Cheers!