There are two kinds of JavaScript functions in Saola Animate: normal function and event handler.
A normal function can have any number of arguments, while an event handler has fixed arguments (doc for the document, and e for the event).
You can add a normal function from Function pane, call it in any functions, and pass variables as its arguments.
To pass variables to an event handler, you need to set them as properties of an object that can be accessed inside the handler, usually the doc object or the event current target object (this).
For example:
\\ a normal function
function startTimeline(doc, timelineName) {
var timeline = doc.getTimeline(timelineName);
if (timeline)
timeline.play(0);
}
\\ a button click event handler
function onButtonClicked(doc, e) {
// call normal function: start timeline having the same name with the button
startTimeline(doc, this.name);
}
There’s no API to animate an object yet, unfortunately.
You can add an interactive timeline from Timeline pane to animate an object, and use JavaScript or a Start Timeline action to run that timeline.