Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Digital Audio, Video > Adobe Flash

  • Print
  • + Share This
This chapter is from the book

This chapter is from the book

The eGreeting Interface

By now, you have thoroughly explored the cardtemplate.fla file and know how to use it to build eCards. The next step is to take a look at the movie that will be the user interface, where the eCard users will pick a card and personalize its message and recipient.

cardSender.fla is the main movie of eGreetings. In its contents is an ActionScript object that sends eCard data through a server-side script into a database and also receives data sent back from the server-side script. It is here that the project begins to tie the eCard movies with user-defined data and backend server connections.

Take a few moments to examine the layout of cardsender.fla, referring to this figure. You will look closer at the ActionScript contained in its frames after you've come to understand the role that the Access database will play.

Figure 10.5. The contents and code in each of the three sections of cardsender.fla are shown here. Use this as a reference as you examine the contents of the file.


Macromedia Flash MX: One thing to note in cardsender.fla is the use of different types of buttons. Flash MX introduced a new kind of movie clip called a button movie clip that acts like a button and allows the code that the button will execute to go inside the clip (usually in frame 1) instead of on the clip. This makes it possible to reuse a button within a Flash movie without having to copy the code to each instance of the button (or go back and change it on all instances if the code changes).

In cardsender.fla, the View and Send buttons in frame 1 are button movie clips. To define the actions that will be carried out when the button is pressed, you define a function that will be used as an event handler for the button and assign that function to the button's onRelease property. This is the code that appears in frame 1 of the actions layer in the viewButtonMC symbol:

function viewit() {
  // load selected card
  root.cardID = this._name.substr(4,2);
  loadMovieNum("card" + _root.cardID + ".swf",1);

this.onRelease = viewit;

Code Listing 4: Putting code inside a button movie clip allows that same code to be used for all instances of the button movie clip, something that could not be done with buttons previously.

By giving the button movie clips appropriate names (View01, View02, and View03 in this example), you can use the same code in each clip to get the ID of the card associated with the button from a substring of the button's name, set variable cardID accordingly, and then open the corresponding card movie in level1. Other frames in the button movie clip are used to specify the button's over and down states. A stop(); must be added in frame 1 to keep those frames from being executed when the button is not being moused over.

cardsender.fla also contains standard buttons (the Preview, Send, and Back buttons in the send frame). Because the code is different on each of these buttons, you use a standard button with code placed on the button rather than within it. On the Preview button in the frame labeled send, for example, you'll see this code:

on (release) {
  preview = 1;
  loadMovieNum("card" + _root.cardID + ".swf",1);

Code Listing 5: If a button is used instead of a button movie clip, code must be placed within an on (<event>) handler, in the button's Object Actions.

This enables the user to preview the card specified by variable cardID with any information the user has entered on the form included.

  • + Share This
  • 🔖 Save To Your Account