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

Home > Articles > Design > Adobe Creative Suite

  • Print
  • + Share This

Targets

Now that you know how to use events to trigger an action, you need to learn how to specify which object, or target, will be affected by the event that occurs. Events control three primary targets: the current movie and its timeline, other movies and their timelines (such as movie-clip instances), and external applications (such as a browser). The following sample ActionScripts show how each of these targets can be used to create interactivity. More in-depth explanations follow.

In the following script, a Roll Over (event) on a button in the current movie (target) causes the movie's timeline to stop playing (action).

  On (Roll Over)
    Stop 
  End On 

In the following example, a Roll Over (event) on a button in the current movie causes a different movie's timeline—the movie-clip instance MyMovieClip (target)—to stop playing (action).

  On (Roll Over)
    Begin Tell Target ("/MyMovieClip")
      Stop 
    End Tell Target 
  End On 

The following ActionScript opens the user's default browser (target)—if it's not already open—and loads the specified URL (action) when the Roll Over (event) is triggered.

  On (Roll Over)
    Get URL ("http://www.crazyraven.com") 
  End On 

Current movie (default target)

The current movie is a relative target, which means it contains the button or frame that triggers an action. Thus, if you assign a mouse event to a button, and that event affects the movie or timeline that contains the button, your target is considered the current movie (Figure 7). If however, you assign a mouse event to a button that affects a movie other than the one that it's a part of, your target becomes a Tell Target. Same principle applies to frame actions. Unless you define a Tell Target as your target, ActionScripts will by default target your current movie for most events. For an example, take a look at the following ActionScript:

  On (Roll Over)
    Go To and Stop (Scene 5, 20) 
  End On 

This ActionScript indicates that a mouse event triggers the action. When the button in your movie is rolled over (event), the current movie's timeline (target) jumps to Scene 5, Frame 20, and begins playing (action) from there.

If you attached the above ActionScript to a button in the main movie—and you didn't use a Tell Target to target another movie—the main movie is considered the current movie. If, however, you attached the same ActionScript to a button in a movie-clip symbol—and didn't use a Tell Target to target another movie—that movie clip would be the current movie (Figure 8). Just remember: The current movie—which is where the triggering event originates—is a relative target used in any ActionScript.

Other movies (Tell Targets)

A Tell Target is a movie controlled by an event in another movie. Thus, if you assign a mouse event to a movie-clip button so that it affects a different movie clip or timeline than the one that contains the button, your target is considered a Tell Target (Figure 9). Compare the following ActionScript for controlling a Tell Target with the ActionScript in the previous example used to control the current movie:

  On (Roll Over)
    Begin Tell Target ("/MyMovieClip")
      Go To Stop (Scene 5, 20)
    End Tell Target 
  End On 

Figure 9

When an event, such as a mouse event, causes another movie's timeline to react in some way (for example, stop), the target for the event is considered a Tell Target.

This ActionScript indicates that a mouse event triggers the action. When the button in your movie is rolled over (event), another movie's timeline (the movie clip called MyMovieClip) (target) will jump to Scene 5, Frame 20, and begin playing (action) from there.

If you find the concept of controlling one movie via another confusing, hang in there. We're going to continue to look at these concepts throughout this chapter (Chapter 11). For more information, see "Working with Multiple Movies" later in this chapter or review some of the interactive tutorials available on the CD that comes with the book.


TIP  You only use Tell Target to control movie-clip instances or movies that are loaded with the Load/Unload Movie action within one Flash Player window. You cannot use Tell Target to communicate between two movies placed on an HTML page with separate <object> or <embed> tags.


External (such as a browser or projector)

An external target exists outside the realm of your movie. With the Get URL action, for example, you need a Web browser to actually open the specified URL. Three actions can target external sources: Get URL, FS Command, and Load/Unload Movie. All of these actions require the help of an outside application. Targets for these actions can be Web browsers, Flash projectors, Web servers, or other applications (for more information see Actions). The following ActionScript targets a Flash projector window:

  On (Roll Over)
    FS Command ("fullscreen", "true")
  End On 

This ActionScript indicates that a mouse event triggers the action. When the button in your movie is rolled over (event), the projector window becomes full screen. The projector window is considered an application window and thus an external target.

  • + Share This
  • 🔖 Save To Your Account

Related Resources

There are currently no related titles. Please check back later.