Adobe 0046100128056 - InDesign - Mac Manual page 160

Javascript
Table of Contents

Advertisement

C
11: Creating Dynamic Documents
Working with Animation 160
HAPTER
, and having the trigger event
requires five mouse
timingTarget
DynamicTriggerEvents.onPageClick
clicks to process all the animations.
//Given a document "myDocument" and a page "myPage" and the color "myColorA",
//"myColorB", and "myColorC"...
//Add a page items to animate.
var myPolygonA = myPage.polygons.add({fillColor:myColorA,
strokeColor:myDocument.swatches.item("None")});
myPolygonA.paths.item(0).entirePath = [[72, 72], [72, 144], [144, 108]];
var myPolygonB = myPage.polygons.add({fillColor:myColorB,
strokeColor:myDocument.swatches.item("None")});
myPolygonB.paths.item(0).entirePath = [[72, 72], [72, 144], [144, 108]];
var myPolygonC = myPage.polygons.add({fillColor:myColorC,
strokeColor:myDocument.swatches.item("None")});
myPolygonC.paths.item(0).entirePath = [[72, 72], [72, 144], [144, 108]];
var myPolygonD = myPage.polygons.add({fillColor:myColorA,
strokeColor:myDocument.swatches.item("None")});
myPolygonD.paths.item(0).entirePath = [[72, 144], [72, 216], [144, 180]];
var myPolygonE = myPage.polygons.add({fillColor:myColorB,
strokeColor:myDocument.swatches.item("None")});
myPolygonE.paths.item(0).entirePath = [[72, 144], [72, 216], [144, 180]]
var myPolygonF = myPage.polygons.add({fillColor:myColorC,
strokeColor:myDocument.swatches.item("None")});
myPolygonF.paths.item(0).entirePath = [[72, 144], [72, 216], [144, 180]];
//Create a motion path.
var myMotionPathPointsA = [[[[108,108],[108,108],[108,108]],[[516, 108],[516,
108],[516, 108]]],true];
var myMotionPathPointsB = [[[[108,180],[108,180],[108,180]],[[516, 180],[516,
180],[516, 180]]],true];
//Set animation preferences for the polygons.
//DynamicTriggerEvents.onPageLoad (the default).
myPolygonA.animationSettings.duration = 2;
myPolygonA.animationSettings.motionPathPoints = myMotionPathPointsA;
myPolygonB.animationSettings.duration = 2;
myPolygonB.animationSettings.motionPathPoints = myMotionPathPointsA;
myPolygonC.animationSettings.duration = 2;
myPolygonC.animationSettings.motionPathPoints = myMotionPathPointsA;
myPolygonD.animationSettings.duration = 2;
myPolygonD.animationSettings.motionPathPoints = myMotionPathPointsB;
myPolygonE.animationSettings.duration = 2;
myPolygonE.animationSettings.motionPathPoints = myMotionPathPointsB;
myPolygonF.animationSettings.duration = 2;
myPolygonF.animationSettings.motionPathPoints = myMotionPathPointsB;
var myTimingSettings = myPage.parent.timingSettings;
//Remove the default timing list.
myTimingSettings.timingLists.item(0).remove();
//Add a new timing list that triggers when the page is clicked.
var myTimingList = myTimingSettings.timingLists.add(DynamicTriggerEvents.onPageClick);
//Add the polygons to a single timing group.
var myTimingGroupA = myTimingList.timingGroups.add(myPolygonA, 0);
myTimingGroupA.timingTargets.add(myPolygonB, 2);
myTimingGroupA.timingTargets.add(myPolygonC, 2);
//myTimingGroupB will play on the second page click.
var myTimingGroupB = myTimingList.timingGroups.add(myPolygonD, 0);
myTimingGroupB.timingTargets.add(myPolygonE, 2);
myTimingGroupB.timingTargets.add(myPolygonF, 2);
A given
object can contain multiple
objects, each of which responds to a
timingSettings
timingList
different trigger event. The following script fragment shows a series of animations triggered by

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Indesign cs5

Table of Contents