11. Actions

11.1 Basics

X2D entities are made dynamic through the action tags. Actions allow simple state changes to occur. For instance, a component's appearance can be changed, or a new URL can be displayed, or the movie can be advanced.

Every action has a target object. It can be a component, an animated object, or a browser. By default it is the owner of the action element.

11.2 Component actions

Component attributes can be changed by the <reconfigure> action. An example of one such action follows:

  <reconfigure target="Component1" color="1 0 0 1"/>

The following component attributes can be changed: color, pos, size, alpha, angle, visible, and enabled.

11.3 Container actions

Container actions include <insert> and <remove>. Components, specified by the url attibute, can be added or removed from the target container.

  <insert target="Container1" url="http://iwork/dialog.x2d"/>

11.4 Animation/Movie actions

Animation and movie actions can be used to control the playback of a component animation. The following lists the possible movie actions: play, stop, goto, pause, rewind, and forward. An example tag is as follows:

  <play target="FadeoutAnim"/>

This causes the given animation/movie to play.

11.4.1 Play

The play action causes the target animation to start playing.

11.4.2 Stop

The stop action causes the target animation to stop playing. The next time the animation is played, it will start from the first frame.

11.4.3 Pause

The pause action causes the target animation to stop playing like the stop tag does. The only difference is that the next time the animation is played, it will start from the frame it paused at.

11.4.4 Rewind

The rewind action causes the target animation to go back to the first frame and continue playing.

11.4.5 Forward

The forward action causes the target animation go forward a given number of frames and continue playing. The number of frames to advance can be specified with the frames attribute. The following tag will cause the animation to go forward 10 frames:

  <forward target="FadeoutAnim" frames="10"/>

11.5 Browser actions

Like other objects specified within an X2D file, the browser is also an object that can be the target of a specific actions. In particular, browsers respond to <link> action commands.

For link commands, the referenced URL can either be placed in a new layer/window or in an existing one specified by the window attribute.

  <link target="localviewer" url="http://graphics.stanford.edu/sample.x2d"/>