Variables

Some events in AutoPlay Media Studio contain variables whose values are automatically set whenever that event is triggered. These variables are called event variables. Event variables are local to the event and can be found on some page and object events. When we say they are "local," we mean their values are only available for actions created on that event.

Note: You can find additional information about each event variable by looking at the list of events.

The following event variables are available in AutoPlay Media Studio:

e_Channel

(number) The audio channel whose state has changed. This variable is only available on the On Audio event. One of the following channel values will be returned:

CONSTANT

VALUE

DESCRIPTION

CHANNEL_BACKGROUND

5

Background audio channel.

CHANNEL_EFFECTS

0

Effects channel (used for mouse over, down, and click sounds).

CHANNEL_NARRATION

6

Narration channel (used for voice overs).

CHANNEL_USER1

1

User channel 1. (Only available in the Professional edition.)

CHANNEL_USER2

2

User channel 2. (Only available in the Professional edition.)

CHANNEL_USER3

3

User channel 3. (Only available in the Professional edition.)

CHANNEL_USER4

4

User channel 4. (Only available in the Professional edition.)

CHANNEL_ALL

-3

All audio channels.

e_FSArgs

(string) A string containing the arguments of the last FSCommand fired within the Flash object. This variable is only available on the On FSCommand event.

e_FSCommand

(string) A string containing the last FSCommand fired within the Flash object. This variable is only available on the On FSCommand event.

e_Key

(number) The virtual key code of the key that was pressed. This variable is only available on the On Key event.

e_Modifiers

(table) A table containing three boolean values that describe which modifier keys were held down while the key was pressed. A modifier key is a key that can be held down while another key is pressed, to "modify" it.

There are three true/false values in the table, one for each type of modifier key on the keyboard: shift, ctrl, and alt. You can access these values as e_Modifiers.shift, e_Modifiers.ctrl, and e_Modifiers.alt. This variable is only available on the On Key event

e_State

(string) A string containing the current state of the audio channel. This variable is only available on the On Audio event. One of the following states will be returned:

VALUE

TYPE

DESCRIPTION

Finish

string

The audio channel's track reached it's end.

Pause

string

The audio channel was paused using the Audio.Pause action.

Play

string

The audio channel was played using the Audio.Play action

Stop

string

The audio channel was stopped using the Audio.Stop action.

e_URL

(string) A string containing the URL that has finished loading or is being navigated to. This variable is only available on the On Loaded and On Navigate events.

this

(string) A string containing the name of the object or page where the event is located. This variable is useful for creating generic actions or functions that are not dependent on specific page or object names. For example:

Label.SetVisible(this, false);

This action hides the label object it was created on. For example, if the action was created on the object named "Label1", it would hide the Label1 object. If it was created on the object called "Label2", it would hide the Label2 object.

Example 1: e_Channel, e_State

Often its necessary to be able to detect when an audio track has reached its end so you can respond with some type of action. This example illustrates how to jump to another page when an audio track playing in the narration audio channel reaches the end. Using this design, the visual presentation could be controlled by an audio voice over.

  1. Create a two page project with your second page called "Page2".

  2. Add the following code to the On Show event of your first page. An audio file is needed for this example, so you will need to modify this action so it loads an actual audio file within your project.

- Load a narration track into the narration channel.
Audio.Load(CHANNEL_NARRATION, "AutoPlay\\Audio\\Lesson1.ogg", true, false);

  1. Add the following code to the On Audio event of your first page.

-- If the narration audio channel's track reaches the end, jump to another page.
if ((e_Channel == CHANNEL_NARRATION) and (e_State == "Finish")) then
    Page.Jump("Page2");
end

If you preview your project, the audio file will begin to play when the first page opens. Once that audio track has reached the end, the second page will display.

Example 2: e_Key

In most cases, interaction with an AutoPlay application is accomplished using the mouse. However it's also possible to control some of the functionality through the keyboard by responding to certain key strokes. This example illustrates how navigation can be controlled by key strokes if a mouse is not available.

  1. Create a project with two or more pages.

  2. Add the following code to the On Key event of each page.

-- If the user presses the Enter key, jump to the next page in the project.
if (e_Key == 13) then
    Page.Navigate(PAGE_NEXT);
end

When you preview your project, each time you press the "Enter" key, the next page will be displayed. In the example code, the event variable e_Key is compared to the number 13 which is the virtual key code value for the "Enter" key (carriage return).