Controlling sound playback using behaviors

You can control sound playback using sound behaviors. Behaviors are prewritten ActionScript scripts that you apply to an object, such as a button, to control a target object, such as a sound. Behaviors enable you to add the power, control, and flexibility of ActionScript coding to your document without having to create the ActionScript code yourself.

You can use the Load Sound from Library or Load Streaming MP3 File behaviors to add a sound to your document. Adding a sound using these behaviors creates an instance of the sound. The instance name is then used to control the sound.

To control a sound with a behavior, you use the Behaviors panel to apply the behavior to a triggering object, such as a button. You specify the event that triggers the behavior (such as clicking the button), select a target object (the sound to be affected by the behavior), and select settings for the behavior parameters to specify how the behavior executes.

To load a sound to a file using a behavior:

  1. Select the object, such as a button, that you want to use to trigger the behavior.
  2. In the Behaviors panel (Window > Development Panels > Behaviors), click the Add (+) button and select either Load Sound from Library or Load Streaming MP3 File from the Sound submenu.
  3. In the dialog box that appears, enter the linkage identifier (see Using sounds with Sound objects) or sound location (external MP3 file). Next, enter a name for this instance of the sound and click OK.
  4. Under Event, click On Release (the default event) and select a mouse event from the menu. If you want to use the OnRelease event, leave the option unchanged.

To control a sound using a behavior:

  1. Select the object, such as a button, that you want to use to trigger the behavior.
  2. In the Behaviors panel (Window > Development Panels > Behaviors), click the Add (+) button and select the desired behavior from the Sound submenu.

    The default event and actions for the behavior appear in the Behaviors panel.

  3. Under Event, click On Release (the default event) and select a mouse event from the menu. If you want to use the OnRelease event, leave the option unchanged.
  4. In the dialog box that appears, select the target object (the sound to be affected by the behavior) from the Target dialog box.
  5. Select settings for the behavior parameters and click OK.