Showcase and discover digital art at yex

Follow Design Stacks

Subscribe to our free newsletter to get all our latest tutorials and articles delivered directly to your inbox!

Behavior 5: Toggle AutoSize

Behavior 5: Toggle AutoSize

The Toggle AutoSize behavior allows you to add code to a button so that it toggles the component’s autosize property between True and False. The following instructions show you how to add this behavior to a custom button.

To use this behavior:

  1. Add a Media Playback component to the Stage.
  2. Add a button to the Stage and select it.
  3. Open the Behaviors panel and click the plus (+) icon to access the list of behavior categories. Select the Media Controls category and choose Toggle AutoSize from the list. The behavior’s dialog opens (see Figure 5).

    figure 5

    Figure 5. The Toggle AutoSize dialog box shows the target MediaDisplay (myMediaControl5) selected.

  4. Browse for the media playback instance in the target list in the bottom portion of the dialog box. This targets the instance name of the component displaying the video. A best practice is to use the Relative option for the path, as shown above. If you have problems adding paths to component buttons, try using the Absolute option instead.
  5. Click OK.

Here’s the code that is added to the button:

// Start Toggle AutoSize Behavior 
var m = myMediaControl5
m.autoSize = !(m.autoSize);
// End Toggle AutoSize Behavior

Tip:

  • To achieve the best results with the Toggle AutoSize effect, the MediaDisplay should be larger than the video, as seen in the sample FLA file.

Comments