Entries Tagged as 'flash actionscript'

Intro to Flashvars | Passing variables to flash actionscript from the html embed | Tutorial | passing dynamic variable from php file

Overview

The property “FlashVars” can be used to import root level variables to the flash movie or swf. The flashvars propery is used in codes for embedding flash in the html page. The string of variables passed in as flashvars, will be imported into the top level of the movie when it is first instantiated. Variables are created before the first frame of the SWF is played. The format of the string is a set of name=value combinations separated by ampersand (&) symbols. Here’s some sample embed codes, including object and embed tags:

<object width=”540″ height=”240″ title=”sample”> <param name=”movie” value=”flashvarsTutorial.swf” /> <param name=”flashvars” value=”var1=here&var2=are&var3=my&var4=flashvars” /> <embed src=”flashvarsTutorial.swf” flashvars=”var1=here&var2=are&var3=my&var4=flashvars” type=”application/x-shockwave-flash” width=”540″ height=”240″ ></embed> </object> Actionscript using flashvars :- txt1.text=var1;


Flash and PHP contact form actionscript Creating contact mail form in flash

About php and flash contact form

This is a contact form made in flash and php, it can be used on ‘contact us’ pages.
A flash file contains the form items and when the ’send’ button is pressed it sends the values to mailer.php, this mailer.php sends the email to the receiver.

Few of the benefits of using a flash form instead of a html contact form are:
better user interface
less junk messages (automated scripts cannot send emails through a flash form unless it is decompiled)
Usage details

Upload mailer.php and form.swf on your server in same directory.
In mailer.php you will have to replace ‘email@yourserver.com’ with your email address. Make sure this is an email hosted on that server where you are testing (most server requires this).
Preview

This is a preview of how the contact form looks, you try sending an email to see how form reacts, email will not be sent. It shows a warning if some of the fields are not filled.

<?php
/* —————————
php and flash contact form.
by www.MacromediaHelp.com
—————————
Note: most servers require that one of the emails (sender or receiver)
to be an email hosted by same server, so make sure your email
(on last line of this file) is one hosted on same server.
————————— */

// read the variables form the string, (this is not needed with some servers).
$subject = $_REQUEST["subject"];
$message = $_REQUEST["message"];
$sender = $_REQUEST["sender"];

// include sender IP in the message.
$full_message = $_SERVER['REMOTE_ADDR'] . “\n\n” . $message;
$message= $full_message;

// remove the backslashes that normally appears when entering ” or ‘
$message = stripslashes($message);
$subject = stripslashes($subject);
$sender = stripslashes($sender);

// add a prefix in the subject line so that you know the email was sent by online form
$subject = “Contact form test”. $subject;

// send the email, make sure you replace email@yourserver.com with your email address
if(isset($message) and isset($subject) and isset($sender)){
mail(”email@yourserver.com”, $subject, $message, “From: $sender”);
}?>
Contents of the FLA flash file (ActionScript)
stop();
send_btn.onRelease = function() {
my_vars = new LoadVars();
my_vars.sender = email_box.text;
my_vars.subject = subject_box.text;
my_vars.message = message_box.text;
if (my_vars.sender != “” and my_vars.subject != “” and my_vars.message != “”) {
my_vars.sendAndLoad(”mailer.php”, my_vars, “POST”);
gotoAndStop(2);
} else {
error_clip.gotoAndPlay(2);
}
my_vars.onLoad = function() {
gotoAndStop(3);
};
};
email_box.onSetFocus = subject_box.onSetFocus=message_box.onSetFocus=function () {
if (error_clip._currentframe != 1) {
error_clip.gotoAndPlay(6);
}
};