Different syntax questions for javascript functions

Hello,
i am trying to build a complex animation and i am missing the correct syntax for the following:

  1. How can I give variables to a javascript function?
  2. How can i fadeOut/FadeIn an object via javascript? i can only find the hard hide/show via doc.getElement(‘myelement’).show(false);

Thanks for reply, Anke

Hi Anke,

  1. 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);
    }
  1. 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.

Regards

1 Like