First time here? First time here? Newsletter Signup Newsletter
Search tutorials
Author: Jeffrey F. Hill | Website: http://www.flash-db.com

Part 1 - Setting up the Main Flash Movie

The main Flash movie (Ecards.fla) is your base of operations. This file allows the user to select the e-card they want to send, then allows them to enter custom text which will be sent along with the e-card when they send it to a friend or anyone else they want to. By opening up the Flash Fla file and going over it first you will have a much better understanding of the part that I'm going to go over next. This part of the tutorial is not really necessary if you already have a good working knowledge of Flash 5.

The fla file contains a movie clip named 'ECards'. This movie clip has 5 frames, each frame contains an image of the Ecard you want to send out. This movie clip is used 5 times (1 time for each e-card that you want to allow users to select from). Their are 5 different instances of the movie clip 'ECards', each instance is used to display a different frame of the movie clip - which corresponds to a different image of an e-card. Setting instance Names.

The first image to the right demonstrates this point. This is the first instance of the movie clip 'ECards', their are 5 other instances with instance names of Ecard2, Ecard3, Ecard4, Ecard5, etc. You should be able to easily change this part or add new ones to the list.

In the first frame of the layer 'Actions' their are a couple of lines of actionscript which tell each e-card what frame to display. For example Ecard4 is told to gotoAndStop at frame 4. On frame 4 of their is a preview image of Ecard 4. These commands are shown in the second image to the left. They can also be found in the fla file.

Over each Movie Clip their is a button. This button allows users to select which card they want to send by clicking on it. The buttons contain the following actionscript.

on (release) {
	gotoAndStop (2);
	EcardSelect = "1";

This tells the main movie to gotoAndStop at frame 2. And also sets the variable EcardSelect equal to 1. The actionscript on the button over the second e-card would be exactly the same except the variable EcardSelect would be set equal to 2. The EcardSelect variable will be used throughout.

This brings us to Frame 2 of the main Ecard Movie. This frame contains the actionscript that sets up the preview image of the card that was chosen and also the actionscript that checks the custom text fields and post's that information to the PHP script that sends the card.

In the second frame of the layer 'Actions' their is a line of actionscript as follows:


The 'ECards' Movie clip is again used, only this time it is given an instance name of 'EcardPreview'. This line of actionscript tells this instance of ECards to go to and stop at the frame that corresponds to the variable EcardSelect - that was set when the user clicked on a specific E-card.

Their are a number of text fields in this frame. They are all input text fields. Make sure that you do not have the 'html' checkbox checked off for these text boxes.

The text fields are given the variable names: ToName, ToEmail, FromName, FromEmail, Greeting, and IntroMessage. An example of the text box with the variable name 'ToName' is given to the right. One thing you may want to do is set the Max Chars limit. In this case the limit was set to 70 Characters. In the case of the IntroMessage text you should try to set a limit so that the text is not cut off in your greeting card when somebody sends it.

The last part of setting up the main 'Ecards.fla' file includes sending the custom information to a script which then processes that information.

On the 'Click here to send e-card' button you will find the following text:

on (release) {
	if (ToName eq "") {
		_root.Status = "Please enter the Name of the person your sending this to";
	} else if (FromName eq "") {
		_root.Status = "Please enter your Name";
	} else if (ToEmail eq "") {
		_root.Status = "Please enter the Email address your sending this to";
	} else if (FromEmail eq "") {
		_root.Status = "Please enter your email address";
	} else if (Greeting eq "") {
		_root.Status = "Please enter a greeting message";
	} else if (IntroMessage eq "") {
		_root.Status = "Please enter a Intro Message";
	} else {
		gotoAndStop (3);
		_root.Status = "Sending Ecard - Please Hold";
		loadVariablesNum ("SendEcard.php", 0, "POST");

The first couple if-else statements just check to make sure that the user filled all the fields out. Then if they did it tells the main movie to go to and stop at the 3rd frame of the movie - where the user will see a success 'the message has been sent' notification. Also the loadVariablesNum command post's all of the variables in the movie to a script which later processes the results.

» Level Advanced

Added: 2001-12-04
Rating: 8.95 Votes: 123
(10 being the highest)
» Author
Jeffrey Hill is a freelance web developer from Boulder, Colorado. He specializes in creating and developing dynamic database driven Flash content. Being a recent graduate of the University of Colorado - he somehow finds time to write these tutorials.
» Download
Download the files used in this tutorial.
» Forums
More help? Search our boards for quick answers!


  • There are no comments yet. Be the first to comment!

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.
Featured Flash FLA
» Author: Inocreato
» Title: RaiseTheBlocks
» Description: Raise all the blocks to win the game
Featured Sound Loops
Image for equalize

Audio Player

» Author: TomCat Carty
» Title: The Wood
» Description: Just a little game ending or it can maybe be looped. Recorders with music box and percussion to give the feel of well, I don't know, the woods? Free to use, just credit me. thank you
Latest Font
» Author: Fábio FAFERS
» Description: I created this font for free use. Everyone can apply it in personal or business texts. Its free, but I want to be communicated in case of business use. Donations are accepted to keep the project of free fonts alive! Thank you all
Featured Sound Fx
Image for equalize

Audio Player

» Author: Davisigner
» Description: Hmm... what to say about this one? It's reminiscent of the closing notes of the opening music from the Three Stooges done in a church organ style with a closing cymbal crash. I'll give this one away gratis, but feel free to check out my free loops and potential upcoming license-mandated ones over in the respective part of Flashkit.