startAnimationWait()

The function startAnimationWait() starts an animation group but unlike the function startAnimation() waits for the animation to finish.

Synopsis

int startAnimationWait(int id [, string deletionPolicy] [, mapping options]);

Parameters

  1. Parameters Description
    id

    The ID (> 0) the function createAnimation() returns when creating a parallel or sequential group

    Use this ID when calling the function animate() as first argument to fill the group with separate animations and the to start the specific animation. See the example below:

    g = createAnimation(); .

    startAnimationWait(g, "keep", makeMapping("direction", "Forward"));

    deletionPolicy

    The deletionPolicy can be specified as:

    "keep": defines that the animation is kept after it stops. When "keep" is used, the animation is only deleted when the panel is closed (when a top level group is deleted, all child groups are deleted as well)

    or "delete" (default): deletes itself after it stops (making the group id invalid).

    The "keep" animation option, makes it possible to start the same group a second time or even to run it backwards, specifying the option makeMapping("direction", "Backward");

    options

    The options for an animation group (parallel, sequential) - see chapter createAnimation() can use the options "duration", "loopCount" and "direction"

    The group defines the direction. Mixing directions in the single added animations is not supported. The "pause" animation in a sequential group can be used to delay the start of the following animation.

    "duration"/int ... duration of animation in msecs, the default value is 600ms

    "loopCount"/int ... number of times the animation is run. default=1. (0=don't run; -1=run endlessly.)

    "direction"/string ... "Forward" or "Backward" movement. The default is "Forward". The option "Backward" reverses

    and runs from endValue to startValue

    Three different examples:

    startAnimationWait(g, "keep", makeMapping("duration",500));

    startAnimationWait(g, "keep", makeMapping("loopCount",3));

    startAnimationWait(g, "keep", makeMapping("direction", "Forward"));

    If you want to start an animation with several options, you can add several options to a mapping as follows:

    startAnimationWait("sequential", makeMapping("duration", 500, "loopCount", 3, "direction", "Forward"));

Return value

The function returns 0 when it was executed successfully and -1 in case of errors.

Description

The function startAnimationWait() starts an animation group.

Note that animations need a lot of CPU. When animations run for a longer period of time, this might be noticeable!

Example

Add the example script to the "clicked" event of a graphics object, for example, rectangle or circle. The script moves the graphics object forwards and backwards and changes the background color.


int g;
bool forward = true;
main()
{
  if ( !g )
  {
    g = createAnimation(); /* creates an animation group */
    animate(g, "", "position", this.positionAsDyn, makeDynInt(300,
    200));
    animate(g, "", "backCol", "{54,132,15}", "{248,28,120}");
    /* creates an animation that changes the background color */
  }
  if ( forward )
  startAnimationWait(g, "keep", makeMapping("direction",
  "Forward"));
  else
  startAnimationWait(g, "keep", makeMapping("direction",
  "Backward"));
  /* Starts the animation and moves the graphics object forwards
  and backwards */
  forward = !forward;
}

The following example opens a panel via the function RootPanelOnModule() and moves and scales the panel up when it is opened. Note that in order to use this script, you need panels called "empty.pnl" and ""flyIn.pnl". Add the script to the "clicked" event of a button.


int g;
bool isShown = false;
main()
{
  if ( isShown )
  {
    stopAnimation(g);
    RootPanelOnModule("empty", "empty", flyInModule.ModuleName,
    "");
    /* Opens the panel "empty" in the module "flyInModule.ModuleName
    */
    startAnimationWait(g, "keep", makeMapping("direction",
    "Backward")); /* moves the panel backwards */
    this.fill = "[pattern,[fit,any,arrow_left_modern.png]]"; /*
    fills the button that is clicked with an image */
    isShown = false;
  }
  else
  {
    if ( !g )
    {
      g = createAnimation(); /* creates an animation group */
      flyInModule.visible = true; /* sets the module visible */
      animate(g, "flyInModule", "sizeAsDyn", makeDynInt(0, 0),
      makeDynInt(581, 341), makeMapping("duration", 600));
      animate(g, "flyInModule", "positionAsDyn", makeDynInt(809, 100),
      makeDynInt(34, 170), makeMapping("duration", 600));
    } 
    /* creates an animation by changing the size and the position
    of the panel "flyInModule" */
    startAnimationWait(g, "keep", makeMapping("direction",
    "Forward")); /* Moves the animation "g" forwards */
    RootPanelOnModule("flyIn", "flyIn", flyInModule.ModuleName,
    "");
    this.fill = "[pattern,[fit,any,arrow_right_modern.png]]"; /*
    Fills a button */
    isShown = true;
  }
}

Assignment

Graphic functions

Availability

UI