Home > Articles > Graphics & Web Design > Dreamweaver & Flash

Your First ActionScripts

  • Print
  • + Share This
Learn the basics of ActionScripts to get you started in creating movies. With this step-by-step guide, you will create two movies that will send you on your way to more complex efforts.
This chapter is from the book

In This Chapter

  • Using the Actions Panels
  • Moving from Scene to Scene
  • Messing with Movie Clips
  • Changing Movie Clip Properties
  • Another Property-Changing Example
  • Text Fields, Arrays, and Loops
  • What You've Learned

In this chapter, we'll go all the way from your first look at

Using the Actions Panels

The Actions panels are one kind of panel, much like the other panels in Flash, such as Properties, Color Mixer, or Info. You open and close Actions panels like you open and close any other panel in Flash. Any code you place in an Actions panel becomes immediately active—you don't have to save the file to test it. The Actions panel toggles between Frame Actions (Actions that only occur within the timeline), Movie Clip Actions (Actions attached to movie clips), and Button Actions (Actions buttons). Button and Movie Clip Actions are pretty much the same thing: actions attached to things on the stage, as opposed to a frame in the timeline.

The Panels

Let's open one of the Actions panels up.

  1. Open a new Flash file with File New.

  2. Window Actions.

  3. Now click on Frame 1 on the timeline. The panel's title changes to "Actions - Frame," as shown in Figure 3–1.

    Figure 01Figure 3–1 The Frame Actions panel

  4. Open the Common Libraries that came with Flash MX by choosing Window Common Libraries Button. Drag any of the buttons to the stage.

  5. Now choose Window Common Libraries Learning Interactions, and drag one of the movie clips to the stage.

  6. Click on the button on the Stage. The panel's title changes to "Actions - Button."

  7. Click on the movie clip on the Stage. The panel's title changes to "Actions - Movie Clip."

As you can see, the same panel serves for frame actions, button actions and movie clip actions. It's easy to make a mistake and enter your actions in the wrong panel, so make sure you check every time before you start entering code.


If some of your actions suddenly disappear, check your frame and movie clips and buttons. You may have entered your actions in the wrong panel. It happens to the best of us. Frequently.

Let's look at all of the parts of an Actions panel. To see everything, let's look at an Actions panel that has something interesting in it.

  1. Open the file chapter3/drag_jake2.fla.

  2. Click on the small fish (the one without all the teeth).

  3. Open the Actions panel.

  4. The panel should resemble Figure 3–2.

    Figure 02Figure 3–2 The parts of an Actions panel

Normal Mode Versus Expert Mode

Actions panels open up automatically in Normal Mode, unless you've changed your preferences. Normal Mode is Flash-assisted scripting—you drag commands from the Toolbox list to the Action list, and Flash prompts you for what parameters you should fill in. You aren't allowed to type commands directly into the scripting window while in Normal Mode.

Normal Mode can be helpful, since your actions are likely to be free of syntax errors. However, Normal Mode can act as something of a crutch, because you don't have to remember all the parts of a command—Flash always tells you—so I strongly recommend that while you're learning ActionScript, you always switch to Expert Mode. Expert Mode allows you to type in everything: commands, parameters, and so on. You'll make more mistakes at first, but you'll learn ActionScript better, and that's our goal. So let's change our panel to Expert Mode.

  1. Open the View Options menu in the Actions panel, as in Figure 3–3.

    Figure 03Figure 3–3 Switching to Expert Mode

  2. Choose "Expert Mode."

  3. I also recommend choosing "View Line Numbers." It will help later when we're troubleshooting our code.

  • + Share This
  • 🔖 Save To Your Account