Add a print button to the e-Card Builder

Author: Matt Slaybaugh
Date: October 12, 2006
Level: Beginner

Summary

E-Card Builder allows users to create electronic greeting cards from a collection of background images, animations, and personal messages. In this tutorial, you will add a 'print' button.

Experience Needed
Software
  • Flash 8
Files — Ecard_peace.zip (889KB)
  • ecard_peace.fla
License — "e-Card Builder" (c) 2007, World Wide Workshop Foundation

This software is licensed to the public under the CC-GNU GPL.

Description

There is a 'print' button on the preview screen, but the recipient should also be able to print the e-card. It is easy to copy the button from one screen and paste it into another.

The print button on the preview screen has Actionscript code associated with it that tells the users printer to print the e-card. All you have to do is copy and paste the button and make sure the new button has the same code in it.

Note that the text on the button that reads print is not part of the button and will need to be copied and pasted separately.

  1. Open ecard_peace.fla in Flash
  2. In the preview screen, locate the print button.
  3. Select the button and copy it by either:
    1. Pressing ctrl-c on your keyboard
    2. Right mouse-click and select copy from the pop-up menu.
    3. Or select Copy from the main Edit menu.
  4. In the timeline move to the recipient screen and paste the button you just copied somewhere on the screen. Paste by either:
    1. Pressing ctrl-v on your keyboard
    2. Right mouse-click and select paste from the pop-up menu
    3. Or select Paste from the main Edit menu
  5. The button will probably not be where you want it. Select the Make your own e-Card button and drag it to make room for the print button.
  6. Once you have the print button in place, add text to read print. Go back to the preview screen and select the text that reads print. Copy it, then return to the recipient screen and paste the text over the new button.
  7. Next, select the button and open the Actions panel. You should see the same code you saw before. If you dont, simply copy and paste the code from the other print button into the actions panel.
More Project Ideas
Starting Projects

Flash / ActionScript Projects

  • Replace the background images with your own
    Create your own backgrounds in Photoshop or another image editor and import them into the library —Note: The backgrounds (5 per theme) are all of the dimensions 533x300 pixels Open the background_selector movie clip and replace the existing images with your own

PHP / HTML Projects

  • Edit the HTML form in send.php so that the message window is larger
    Use the attributes rows and cols in the textarea tag to make the message window wider and longer.

Intermediate Projects

Flash / ActionScript Projects

  • Change the parameters of the print function
    The print feature is included in code associated with the print button. Select the button and look in the Actions window to see the code.
    Change the x and y values to change how much of the screen gets printed.

PHP / HTML Projects

  • Add PHP code to email.php so that the outgoing message includes information about the time and date that the card was sent.

Advanced Projects

PHP / HTML Projects

  • Combine all the PHP files into a single document, using methods for the different functions of printing, sending mail, displaying the SWF to the recipient, and displaying the SWF to the person editing the card.
More ECard Resources
Programming Notes and Common Mistakes
  • In ActionScript and PHP, there is a difference between = and ==.
    • A single equals sign (=) means you are giving a variable a value.
    • A double equals sign (==) means you are checking to see whether a value has a particular value.
  • In PHP, variables all start with a dollar sign ($). In ActionScript, variables do not need any special characters.
  • In both PHP and ActionScript, lines end with semicolons (;)
  • In both PHP and ActionScript, comments are indicated with a double slash (//) at the beginning of the line. Comments are notes to yourself or other programmers that are ignored by Flash when it compiles the SWF.
  • In ActionScript, its often handy to see what the value of a variable is when coding and debugging. Use the trace command in the code to show the value of a variable
    • Eg.
    • trace ("the value of which_animation is: "+which_animation);
  • Any movie clip that is called by ActionScript to be attached into another clip needs to have its "linkage" set. Right-click on the movie clip, select Linkage... and select Export for ActionScript
  • In ActionScript and PHP, arrays start counting at zero (0). Because the Flash timeline starts counting at one (1), its often handy to begin arrays at 1 as well, by placing null values in the initial cell of the array.
    • Eg.
    • My_array = ("null", "first value", "second value", ...);
  • ActionScript and HTML use a hexadecimal (base-16) system for indicating colors. The 6 digits are three sets of two digits, ranging from 00 to FF, for the red, green, and blue values. 00 equals no color and FF equals full color.
    • Eg. 000000 is black (no color in any channel)
    • FFFFFF is white (full brightness in all three channels)
    • FF0000 is bright red (full brightness in the red channel only)
    • FFFF00 is yellow (full brightness in red and green, none in blue)