ActionScript 3.0 Design Patterns

(Chris Devlin) #1
Dynamically Changing States | 309


  1. Click on the Export for ActionScript checkbox in the Linkage group. You should
    see the Export in first frame checkbox automatically selected. Also, in the Class
    window, you should seeAndroidappear andflash.display.MovieClipin the
    Base class window. Click OK.

  2. You are now in the Symbol edit mode. Using the drawing tools, draw a penta-
    gon with the dimension W=57, H=54. Click the Scene icon when you’re fin-
    ished, and you should see your space station movie clip in the Library.

  3. Select Insert➝ New Symbol from the menu bar.

  4. When the New Symbol window opens, type inBeamin the Name window, and
    select Movie clip as the Behavior. If you see a button named Advanced, click it.
    It opens up part of the New Symbol window that you need for the next step.

  5. Click on the Export for ActionScript checkbox in the Linkage group. You should
    see the Export in first frame checkbox automatically selected. Also, in the Class
    window, you should seeBeamappear andflash.display.MovieClipin the Base
    class window. Click OK.

  6. You are now in the Symbol edit mode. Add two layers to the existing layer.
    Name the top layer “Actions,” the middle layer “Left,” and the bottom layer
    “Right.”

  7. Click on Frame 20, select the frames for all three layers, and press F5 to add 20
    frames to all the layers. Click on the first frame of the Actions layer, and, in the
    Actions panel, type instop( );.

  8. Click on the first frame of the Left layer. Select the Line tool and set the Stroke


height in the Properties panel to 6. (The Stroke height sets how wide the line will
be.) Select green for the line color. With the base at the X=0, Y=0 position, draw
a line at a -45 ̊ angle about 12 pixels long. You may have to reposition the base
to the center position mark in the Symbol editor.


  1. Click on the first frame of the Right layer and repeat step 10, but angle the line


to +45 ̊. When finished, you should see a V-shaped drawing with the base of the
V at the X=0, Y=0 position.


  1. Select the Left layer, click on Frame 20, and press the F6 key to add a keyframe.


Select the green line and change the color from green to purple. Set the line
dimensions to W=240, H=220 and reposition the base of the line to the center
crosshair.


  1. Repeat Step 10 with the line in the Right layer, except that the dimensions


should be set to W=220, H=240. You should see a large purple “V” when you’re
finished.


  1. Click on the first frame of the Left and Right layers, and select Shape for the


tween. Press the Enter/Return key to test the movie. You should see a “beam”
shoot out to the left and right, changing from green to purple. Figure 8-5 shows
the beam being “fired” at the two ships.
Free download pdf