• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

Chapter 15. Using Basic ActionScripts > Working with Frame Events

Working with Frame Events

Frame event handlers are easy to understand. When an action is attached to a frame, the action is triggered when the play head hits the frame. For example, you want to create a frame event that swaps images on the Stage, and you want the images to swap every 40 frames. You can attach an ActionScript that swaps the image, and place the action every 40 frames. When the play head hits the frame, the action executes. When you attach an ActionScript to a frame, you'll need a blank keyframe on the Timeline, and it is strongly recommended that you always place ActionScripts in a separate layer from access, and control. In addition, if you're planning to swap images in a Flash movie, it's always best to use a blank movie clip (called a placeholder), to hold the images.

Attach an ActionScript to a Frame

Drag a blank movie clip onto the Stage, and then select the clip.

Give the movie clip a unique instance name, in the Property Inspector.

Create a new layer, and then name the layer.

Create blank keyframes at frame numbers 1, 21, 41, and 61.

Select a frame, click the Insert menu, point to Timeline, and then click Blank Keyframe.

Select frame 1, and then enter the script as shown in the illustration.

Select frames 21, 41, and 61, and then repeat the script, except change the name of the image you want to load (image_b.jpg, image_c.jpg, image_d.jpg).

Click the Control menu, and then click Test Movie.



Not a subscriber?

Start A Free Trial

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint