Send data from Flash to ASP and back to Flash


I need to send data from Flash (I'm a novice in) to ASP and the result back from ASP to Flash.
I found this example (in German language) how to do.
Well it works but only sometimes - almost I see in the browser status bar that data will be send and when the browser shows ready I don't get any result.
So I looked for a better sample but at all I found only samples that send data from Flash to ASP and not back...
Maybe somebody can show my why this sample allmost do not work or has somebody a better sample for?


Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I translated the site you sent and also found a related article which shows how to set cookies in flash.
So you can set a cookie from asp and read it in flash.
andre72Author Commented:
I'm sorry. I made a mistake because of bad description.
I can't use cookies or parse parameter using html for the embeded object because I need to exchange the parameters at runtime and without change to an othere side.
Enter your E-Mail address into a flash movie
Flash givie this E-Mail addresse to send the mail and return the state to flash
flash shows if anything is right or something goes wrog
Unfortunately I am not great with ASP however I have created a PHP version of what you are looking for many times.

If you are just looking for a contained solution this should do the job for you, if you are completely against PHP I may be able to recode it.

You can download the source files for this from

The Flash Code is just the function, you would need to have input textboxes for nameInput, phoneInput, etc. as well as a dynamic field called Output.  Create a button that will run the function sendEmail() and it will pass the information from the input boxes to SendEmail.php

It will pass the information to the php, the php will process that information and send back if the job was successful or not.  The code is commented and should explain it all.  There is only one thing, you will need to have the directory "inc" and it's files (from the zip link above).  Place the directory in the same one as the files you are running.

I hope this helps.
function sendEmail(){
	//Create the object to hold the variables
	email = new LoadVars();
	//enter the variables to be sent to the php form = nameInput.text; = phoneInput.text;
	email.postcode = postcodeInput.text; = emailInput.text;
	email.comments = commentsInput.text;
	email.success = 0;
        //send and receive variables
	email.sendAndLoad("SendEmail.php", email, "POST" );
	email.onLoad = function(success){
		//test to make sure the send and load to php was successful
		//if it fails at this point it is due to the php having an error
		//or you are pointing to a file that doesn't exist
				//Result if Email Sent
				Output.text = "email sent";
				//Send the email error from the php script
				Output.text = this.error;
			Output.text = "System Error";
//CODE FOR PHP.  Name file SendEmail.php
//The inc directory is in the I have linked to.
//receive the variables from flash
$name = $_POST["name"];
$phone = $_POST["phone"];
$postcode = $_POST["postcode"];
$email = $_POST["email"];
$comments = $_POST["comments"];
//create a variable for the date
$date = date("r");
#Make the body text for the email to be sent to Kombat
$alltext = "
This is the email we will be sending
Name:       $name  
Phone No.:  $phone  
Post Code:  $postcode  	
Email:      $email
******END OF EMAIL******
//This will wrap the email so that it is no wider than 55 characthers
//this is only to make sure the comments won't show up as one line of text
$allwrap = wordwrap($alltext, 55, "\n", 1);
//The if statement tests to make sure that the email entered isn't a fake
//this can be removed but is good to prevent spammers.  It refers to the 
//function validate Email below.
  if(validateEmail($email) == false){
  	//If check fails, send back that we failed due to an invalid email address
    echo "success=0&error=invalid email";
	 $mail = new htmlMimeMail();
	 //set the body of the email to the input from above
	 //set the email from field
	 $mail->setFrom("\"Your Name\" <>");
	 //set the email subject field
	 $mail->setSubject("Subject for Email To Customer");
	 //set the email header
	 $mail->setHeader('X-Mailer', 'Email Form');
	 //add a date to the header
	 $mail->setHeader('Date', "$date");
	//send the email to the email address entered
		//return 1 to show a successful send
        echo "success=1";
		//return 0 to show an unsuccessful send with an error message
        echo "success=0&error=email not sent";
#  Validate the email address
function validateEmail($email)
   #Make sure the email uses the correct layout eg.
   if(eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]", $email)){
      return false;
   #Retrieve the domain name from the email address.
   list($Username, $Domain) = split("@",$email);
   #Check the MX Record to make sure the domain exists.
   if(getmxrr($Domain, $MXHost)){
      return true;
      if(fsockopen($Domain, 25, $errno, $errstr, 30)){
         return true; 
         return false; 

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.