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.

CHANNEL_USER2

2

User channel 2.

CHANNEL_USER3

3

User channel 3.

CHANNEL_USER4

4

User channel 4.

CHANNEL_ALL

-3

All audio channels.

e_Checked

(boolean) True if a node in the tree object has been checked, false if it has been unchecked. This variable is only available on the On Check event.

e_Expanded

(boolean) True if a node in the tree object has been expanded, false if it has been collapsed. This variable is only available on the On Expanded event.

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_ID

(number) The item ID of the menu item currently being interacted with.

e_ItemInfo

(table) Extended information about the currently selected menu item.

KEY

TYPE

DESCRIPTION

Text

string

The text of the menu item currently being interacted with.

ID

number

The item ID of the menu item currently being interacted with.

Enabled

boolean

True if the current menu item is enabled, false if it is not.

Checked

boolean

True if the current menu item is checked, false if it is not.

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_NewText

(string) The text that has just been set for a node in the tree object. This variable is only available on a tree object's On EditLabel event.

e_NodeIndex

(string) The index of a node in the tree object.

e_OldText

(string) The text that existed previously before the user edited the text of a node in the tree object. This variable is only available on a tree object's On EditLabel event.

e_PageHeight

(number) The height of the current page. This variable is only available on the On Size event.

e_PageWidth

(number) The width of the current page.  This variable is only available on the On Size event.

e_Selection

(number) The index of a comboxbox item that is being selected. (The first item in the list has an index of 1.) This variable is only available on the On Select event of a combobox object.

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_Type

(number) The type of resize that has occurred if on the On Size event, or the type of mouse button click if on the On Mouse Button event.

On Size e_Type constants:

CONSTANT

VALUE

DESCRIPTION

SIZE_RESTORED

0

The application was either restored from being maximized or minimized or was resized normally.

SIZE_MINIMIZED

1

The application was minimized to the taskbar.

SIZE_MAXIMIZED

2

The application was maximized.

On Mouse Button e_Type constants:

CONSTANT

VALUE

DESCRIPTION

LEFT_BUTTON_DOWN

0

Left mouse button has been pressed.

LEFT_BUTTON_UP

1

Left mouse button has been released.

RIGHT_BUTTON_DOWN

2

Right mouse button has been pressed.

RIGHT_BUTTON_UP

3

Right mouse button has been released.

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.

e_WindowHeight

(number) The height, in pixels, of the entire application window, including the border and title bar.  This variable is only available on the On Size event.

e_WindowWidth

(number) The width, in pixels, of the entire application window, including the border and title bar.  This variable is only available on the On Size event.

e_X

(number) The horizontal position of the mouse cursor, in pixels, from the left side of the page. This variable is only available on the On Mouse Button and On Mouse Move events.

e_Y

(number) The vertical position of the mouse cursor, in pixels, from the right side of the page. This variable is only available on the On Mouse Button and On Mouse Move 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).