This is a discussion on mailTo method within the Tutorials forums, part of the Flash English category; Do you remember the old method mailto of Actionscript 2.0 used together with getURL that allowed to open the ...
In this tutorial, I will show how to use 2 different methods, a simple one and a more complex one.
Example 1
I create a FLA and I save it as "main.fla".
Into which, I create a button that I instantiate on stage and I assign to it the instance name "myButton".
I open the action panel and I write:
Code:
function openMailClient(event:MouseEvent):void
{
var request:URLRequest=new URLRequest();
request.url="mailto:info[noSpam]flepstudio.org";
navigateToURL(request,"self");
}
myButton.addEventListener(MouseEvent.CLICK,openMailClient);
And this the result:
Let us analyse the code
In the function openMailClient, I declare a new variable of type URLRequest and I assign to it as URL a string that contains the command mailto: followed of the eMail address to which the Mail Client (for example Outlook Express) will send the message.
Next, I use the method navigateToURL and I pass to it, as parameters, the variable URLRequest (named "request") and "_self".
I add a listener to the event MouseEvent.CLICK to "myButton" that will call the function openMailClient on click of the mouse on the button.
Example 2
With this example, other then passing the value for the eMail address to the user"s Mail Client, we will also pass the subject and body of the message.
I create a FLA and I save it as "main2.fla".
Into which, I create a button. I instantiate it on stage and I assign the instance name "myButton".
I create 3 text fields: 2 dynamic ones named "to_txt" and "subject_txt" and the third one, an input text field named "body_txt".
I open the panel action and I write:
Code:
to_txt.text='info@flepstudio.org';
subject_txt.text='eMail from website';
function openMailClient(event:MouseEvent):void
{
var request:URLRequest=new URLRequest();
request.url="mailto:"+to_txt.text+""subject="+subject_txt.text+"&body="+body_txt.text;
navigateToURL(request,"_self");
}
myButton.addEventListener(MouseEvent.CLICK,openMailClient);
And this is the result:
The code used is based on the first example.
The difference is that we add parameters to the url of the variable "request" which is also of type URLRequest.
I figured out that the culprit is Windows Explorer because it doesn't happen in Firefox. Is there a script I can put in the html to say no pop-up? Or is there another way around this?
I'm flabbergasted! I can't make this work (either method) when I code it in Flash. My site is in CS3. Could that be the reason? Any help appreciated. Thanks!!
I'm flabbergasted! I can't make this work (either method) when I code it in Flash. My site is in CS3. Could that be the reason? Any help appreciated. Thanks!!
You are using flash cs3, ok...but are you using actionscript 3.0?
Onsitus ... I know I am using CS3 because that's what the splash screen says. I have no idea what version of AS was used on the original template. Honestly ... other than being able to turn on my PC with either hand, I can't do much more. Any guidance is appreciated. I am willing to learn. Take care and thanks!