Actions and Event Handlers Flash

Even the most complex interactivity in Flash is fundamentally composed of two basic parts: (a) the behavior (what happens), and (b) the cause of the behavior (what makes it happen). Here’s a simple example: Suppose you have a looping soundtrack in a movie and a button that, when clicked, turns the soundtrack off. The behavior is the sound turning off, and the cause of the behavior is the mouse clicking the button. In Flash, behaviors are referred to as actions. The first step in learning how to make interactive movies is becoming familiar with the list of possible actions. However, actions can’t act without being told to act by something. That something is often the mouse coming in contact with a button, but it can also be a keystroke, or simply a command issued from a keyframe. We refer to any occurrence that can cause an action to happen (such as the button click in the preceding example) as an event. The mechanism we use to tell Flash what action to perform when an event occurs is known as an event handler. This cause-and-effect relationship seems obvious, but it is an extremely important concept. For the purposes of creating basic interactivity, the difference between an action and the cause of an action is merely a practical detail. But with Flash 5’s new programmatic actions and the scripting capabilities that they provide, understanding the relationship between actions and the things that cause them can be the key to adding more sophisticated behavior to your movies with traditional programming techniques.

Don’t worry, we’re taking it one step at a time. First, we set up the new Frame and Object Actions Panel. Then we look at the Basic Actions booklet. Later, we see how to call these actions in various ways with three kinds of event handlers: button manipulation, keyframes, and keystrokes.

What is ActionScript?
Every interactive authoring system uses a language (or code) that enables elements within the system to communicate. Just as there are several languages that people use to speak to one another around the globe, there are hundreds of programming languages in use today. In an effort to make Flash more usable to computer programmers, Flash’s scripting language, called ActionScript, has changed much of its formatting to mirror JavaScript, a fundamental component for DHTML and HTML Web pages. Right now, we focus on using the most basic Flash ActionScript.

Setting up the Actions Panel
Unlike previous versions, Flash 5 has a new way of adding interactive commands to Flash movies the Actions Panel. Unlike with previous versions of Flash, you do not have to double-click frames and buttons to access actions. Also, you don’t have to use menus to select Actions you can type them by hand in or out of Flash! To open the Actions Panel, go to Windows➪Actions (Option+Command+A or Ctrl+ Alt+A). If you have a frame selected in the timeline, you will see the Actions Panel with the name Frame Actions (see Figure below). If you have a Button or Movie Clip symbol selected on the stage, you’ll see the name Object Actions. Don’t be confused there is only one Actions Panel. Flash simply lets you know the event handler to which you are assigning actions.

Most actions have user-definable parameters that can be set in the gray area below the left and right panes of the Actions Panel. You can show or hide this area by clicking the arrow in the lower-right corner of the panel. You can also hide the left pane of the Actions Panel by clicking the arrow on the divider line between the left and right panes.

The new Actions Panel enables you to instantly add, delete, or change Flash interactive commands.

new Actions Panel enables you to instantly add, delete, or change Flash interactive commands.

Normal versus Expert Mode
Flash has two authoring modes for actions: Normal and Expert. By default, Flash uses the Normal Mode (Command+N or Ctrl+N when the Actions Panel is active). In this mode, Flash arranges actions in the left pane into six booklets, each booklet containing sets of ActionScript. You can choose actions from any of the sets by double-clicking a specific action. We work entirely within the first booklet, Basic Actions. In Expert Mode (Command+E or Ctrl+E when the Actions Panel is active), Flash eliminates the Basic Actions booklet (they’re all included in the Actions booklet), and enables you to type, copy, cut, and paste code at will into the right pane of the Actions Panel. You can change the mode setting by accessing the Actions Panel options, located at the upper-right corner of the panel .

You can add actions by dragging them from the left pane to the right pane, by selecting them from the plus (+) menu button in the upper-left corner of the Actions Panel, or by double-clicking them from an Action booklet. To delete actions, select the action line(s) in the right pane, and press the Delete key on the keyboard. Or you can select the action line(s) and push the minus (–) button in the upper-left corner.

You can control the Actions Panel’s look and feel by switching between Normal and Expert Modes.

You can control the Actions Panel’s look and feel by switching between Normal and Expert Modes.

The Basic Actions are listed as unsorted groups according to the functions they can perform. The first group, comprised of Go To, Play, and Stop, control the playback of the movie. The second group, which includes Toggle High Quality and Stop All Sounds, provides global tools for handling sounds and visual quality. The third group Get URL, FSCommand, and Load/Unload Movie let movies load external files and communicate with the browser, a Web server, or the standalone player. The fourth group is effectively made up of Tell Target and If Frame Is Loaded.

Face Book Twitter Google Plus Instagram Youtube Linkedin Myspace Pinterest Soundcloud Wikipedia

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd Protection Status

Flash Topics