Skip to main content
Participating Frequently
October 9, 2013
Answered

AS3 mailto

  • October 9, 2013
  • 1 reply
  • 15835 views

Hi


I'm making a contact form so when you click the submit button it opens up a email window were the subject and message is already fill in because they did it in the contact form. I dont really know which code I should use. I've only gotten this far. The subject and message is textinput and textarea components.


var vEmail:URLRequest = new URLRequest(" mailto:mail@example.com?subject=subjectText&body=bodyText" );

bEmail.addEventListener(MouseEvent.CLICK,fEmailClick);

function fEmailClick(event:MouseEvent):void {

navigateToURL(vEmail," _blank" ) ;

}

This topic has been closed for replies.
Correct answer kglad

use:


var vEmail:URLRequest = new URLRequest(" mailto:mail@example.com?subject="+yoursubjecttextfield.text+"&body="+yourmessagetextfield.text );

bEmail.addEventListener(MouseEvent.CLICK,fEmailClick);

function fEmailClick(event:MouseEvent):void {

navigateToURL(vEmail," _blank" ) ;

}

1 reply

kglad
kgladCorrect answer
Community Expert
October 9, 2013

use:


var vEmail:URLRequest = new URLRequest(" mailto:mail@example.com?subject="+yoursubjecttextfield.text+"&body="+yourmessagetextfield.text );

bEmail.addEventListener(MouseEvent.CLICK,fEmailClick);

function fEmailClick(event:MouseEvent):void {

navigateToURL(vEmail," _blank" ) ;

}

Lunkan87Author
Participating Frequently
October 9, 2013

I didnt work. Still dosent load any subject or message into the email. A stupid question do I have to use import flash.net.URLRequest; or something like that for it to work?

kglad
Community Expert
October 9, 2013

but if I can ask a nother question on another thing. I want to make a external textfile load in to a dynamic textfield when I push a button. I searched online but could fine anything that i could understand. I only got this far with code and it doesnt work. 

var meddelande:TextField = new TextField();

var textURL:URLRequest = new URLRequest("extern.txt");

var textLoader:URLLoader = new URLLoader();

function knappa3(event:MouseEvent):void

{

          textLoader.load(textURL);

          meddelande.text = e.target.data;

          trace("File loaded successfully.");

}

Del1, Layer 'Layer 2', Frame 1, Line 291120: Access of undefined property e.

which is medelande.text = e.target.data;


use:

var meddelande:TextField = new TextField();

addChild(meddelande);

var textURL:URLRequest = new URLRequest("extern.txt");

var textLoader:URLLoader = new URLLoader();

textLoader.addEventListener(Event.COMPLETE,loadcompleteF);

// calling knappa3, starts the loading of extern.txt

function knappa3(event:MouseEvent):void{

          textLoader.load(textURL);

}

function loadcompleteF(e:Event):void{

    meddelande.text = e.target.data;  // you can't assign the data until loading is complete

}