Adobe 0046100128056 - InDesign - Mac Manual page 155

Javascript
Table of Contents

Advertisement

C
11: Creating Dynamic Documents
Creating Buttons 155
HAPTER
//Given a page "myPage" in a document "myDocument," containing the colors
//"Blue" and "Red"...
//Make a button "from scratch."
var myButton = myPage.buttons.add({geometricBounds:[72, 72, 144, 144],
name:"GoToNextPageButton"});
var myRightArrow =
myButton.states.item(0).polygons.add({fillColor:myDocument.colors.item("Red")});
myRightArrow.paths.item(0).entirePath = [[72, 72],[144,108],[72, 144]];
//Add the Rollover state.
var myRolloverState = myButton.states.add();
//Add a shadow to the polygon in the Rollover state.
var myRolloverArrow =
myRolloverState.polygons.add({fillColor:myDocument.colors.item("Red")});
myRolloverArrow.paths.item(0).entirePath = [[72, 72],[144,108],[72, 144]];
var myFillTransparencySettings = myRolloverArrow.fillTransparencySettings;
myFillTransparencySettings.dropShadowSettings.mode = ShadowMode.drop;
myFillTransparencySettings.dropShadowSettings.angle = 90;
myFillTransparencySettings.dropShadowSettings.xOffset = 0;
myFillTransparencySettings.dropShadowSettings.yOffset = 0;
myFillTransparencySettings.dropShadowSettings.size = 6;
//Add a shadow to the polygon in the Click state.
var myClickState = myButton.states.add();
var myClickArrow =
myClickState.polygons.add({fillColor:myDocument.colors.item("Blue")});
myClickArrow.paths.item(0).entirePath = [[72, 72],[144,108],[72, 144]];
//Set the behavior for the button.
var myGoToNextPageBehavior =
myButton.gotoNextPageBehaviors.add({behaviorEvent:BehaviorEvents.mouseUp});
Buttons can be used to control the playback of movie and sound files. The following script fragment shows
an example of using a set of buttons to control the playback of a moving file (for the complete script, refer
to MovieControl).
//Given a page "myPage" in a document "myDocument,"
//containing the colors "Gray" and "Red"...
var myFrame = myPage.rectangles.add({geometricBounds:[72, 72, 288, 288]});
//Import a movie file (you'll have to provide a valid file path on your system);
myFrame.place(File("/c/movie.flv"));
//Create the movie "Start" button.
var myPlayButton = myPage.buttons.add({geometricBounds:[294,186,354,282],
name:"PlayMovieButton"});
var myRightArrow =
myPlayButton.states.item(0).polygons.add({fillColor:myDocument.colors.item("Gray")});
myRightArrow.paths.item(0).entirePath = [[186, 294],[186,354],[282, 324]];
//Add the Rollover state.
var myRolloverState = myPlayButton.states.add();
//Add a shadow to the polygon in the Rollover state.
var myRolloverArrow =
myRolloverState.polygons.add({fillColor:myDocument.colors.item("Gray")});
myRolloverArrow.paths.item(0).entirePath = [[186, 294],[186,354],[282, 324]];
var myFillTransparencySettings = myRolloverArrow.fillTransparencySettings;
myFillTransparencySettings.dropShadowSettings.mode = ShadowMode.drop;
myFillTransparencySettings.dropShadowSettings.angle = 90;
myFillTransparencySettings.dropShadowSettings.xOffset = 0;
myFillTransparencySettings.dropShadowSettings.yOffset = 0;
myFillTransparencySettings.dropShadowSettings.size = 6;
//Add a shadow to the polygon in the Click state.
var myClickState = myPlayButton.states.add();
var myClickArrow =
myClickState.polygons.add({fillColor:myDocument.colors.item("Red")});

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Indesign cs5

Table of Contents