Home/Help/State machine/Actions

STATE MACHINE

Actions

A state can do things as well as play: change a variable, send a message, jump to a frame, open a link, or tell the page around the file. Each action has its moment: when the state starts, at its end, each time a loop ends, or when it leaves. Here the switch counts how often it is turned on, and tells the page.

Do it in the editor: guided tour4 steps · about 3 minutes · opens a practice scene

Step by step

  1. Open the state

    Click On on the chart. Its editor opens upward from the box: how it plays, Does, and Leaves when.

  2. Count it

    Click + beside Does and pick + / −. The row reads as a sentence: When it starts, Times on + 1. Its moment, its variable and the amount are menus and a field on the row.

  3. Tell the page

    Click + again and pick Send to the page, then type switched-on and press Enter. In an exported file the SVG fires a cin:event with that name, for the page's own script.

  4. Try it

    Click the switch on the canvas a few times. Times on, in Variables, goes up each time it turns on, and What happened says what the page would hear.

Good to know. Rows run top to bottom: drag ⋮⋮ to change the order. The chart counts a state's actions on its box (⚡ 2). Any state has its own Does, when the flow starts and when it stops, and its + offers Stay here: an interaction that only does something, without leaving the state. In the preview a link only shows in What happened; in an exported file it opens. Once the file has themes, Switch theme joins the actions.

Keys

EscClose the editor
SpaceStart the preview again