Cool simple demonstration of sending email. Will you be doing a tutorial where sending email doesn't involve triggering the recipient's client email?
paplone
Do you remember the old method mailto of Actionscript 2.0 used together with getURL that allowed to open the mail client of the user"
Do you think that with Actionscript 3.0, it is not possible anymore"
Wrong!
Even with the third version of Actionscript it is possible to use this command. It simply needs to be associated to the new method navigateToURL .
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:
And this the result: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);
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:
And this is the result: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);
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.
Stay tuned !
Last edited by Flep; 28-08-08 at 05:22.
Cool simple demonstration of sending email. Will you be doing a tutorial where sending email doesn't involve triggering the recipient's client email?
paplone
Hi
At the moment you can download the email form:
http://www.flepstudio.org/forum/down...?do=file&id=45
I have a problem when using this code. for some reason a webpage and an email client opens up is there an extra code I need to insert. Here is my code
stop();
email1_btn.addEventListener(MouseEvent.CLICK,email 1);
function email1(event:MouseEvent):void
{
var request:URLRequest=new URLRequest();
request.url="mailto:first.last@cbre.com";
navigateToURL(request,"self");
}
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?
Thanks!
moo74
Flep ... I'm trying to access but I'm not allowed. Could you assist? 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!!
CSS.FlepStudio.org in english: css tutorials, free css template and css menu
Conversione da PSD a XHTML/CSS - Creazione siti web - Introduzione CSS3
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!
I'm dealing with Lotus Notes and a long body text. If the QUERY_STRING is more than about 255 characters, Lotus Notes will not open a new email window.
I can also break your demo above for Outlook buy putting in a very long string of characters in the text area for the body. I suspect that the limit for Outlook is around 1024 characters.
I have tried to use the POST method and put my body data into a URLVariable without success so far. Do you have a demo on how to do that?
Here's what I have tried:
TIA!Code:var uv:URLVariable = new URLVariable(); uv.body = codesTA.text; var emailURL:URLRequest = new URLRequest("mailto:" + emailTI.text + "?subject=your request") emailURL.method="POST" emailURL.data = uv; emailURL.contentType = "text/plain" navigateToURL(emailURL, "_self")
LGRains
Bookmarks