Documentation

Addon Scripting

Script syntax

Example:

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

Where:

  • a - variable name
  • text1, image - the name given to a module in the presentation's editor
  • getIndex, setFrame - is one of the commands supported by the 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 the author to assign code to the specific event.

onClick, event

To send this event, use the following player command:

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

The player will parse the provided script and call appropriate commands.

Reacting to commands from the script

Commands are sent to an addon by the executeCommand function

executeCommand = function(name, params)

There are two parameters:

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

A command can return value as a string.

Good practice

  • If the addon changes its state because 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 the setState() and getState().