Documentation

Addon Scripting

Script syntax

Example:

var a = text1.getIndex();
image.setFrame(a, 'Title');

Where:

  • a - variable name
  • text1, image - name given to a module in the presentation's editor
  • getIndex, setFrame - is one of the commands supported by module
  • a, 'Title' - is the parameter passed to the command

Sending events

To define events, first it is necessary to create an event property in the model. This will allow author to assign code the specific event.

onClick, event

In order to send this event, use the following player command:

playerController.getCommands().executeEventCode(model['onClick']);

Player will parse the provided script and call appropriate commands.

Reacting to commands from script

Commands are sent to an addon by executeCommand function

executeCommand = function(name, params)

There are 2 parameters:

  • name - command name. This name is converted to lowercase.
  • params - array with commands passed to this function. Each param is passed as string.

A command can return value as string.

Good practice

  • If the addon changes its state as a result of the command call, then Reset Page should return the addon to its initial state.
  • The state changed by the command call should be saved and restored by setState() and getState().