Creating Multistate Objects. Adobe CS5 InDesign
Annonce
Annonce
C
HAPTER
11: Creating Dynamic Documents
Creating Multistate Objects 167 set angle to 90 set x offset to 0 set y offset to 0 set size to 6 end tell tell myStopButton set myClickState to make state end tell tell myClickState set myClickRectangle to make rectangle with properties {geometric bounds:
{294, 78, 354, 174}, fill color:color "Red" of myDocument} end tell tell myStopButton set myMovieStopBehavior to make movie behavior with properties {movie item: movie 1 of myFrame, behavior event:mouse up, operation:stop} end tell end tell
Buttons are also important in controlling the appearance of multistate objects, as we’ll demonstrate in the next section.
Creating Multistate Objects
Multistate objects (or MSOs) are similar to buttons in that they contains states, and that only one state can be visible at a time. They are unlike buttons in that they can contain any number of states; buttons can contain three states, at most. Multistate objects rely on buttons to change the way they display their states.
The following script fragment shows how to create a simple multistate object and add a button to control the display of the states in the object (for the complete script, refer to MakeMultiStateObject).
--Given a document "myDocument" and a page "myPage" and
--four colors "myColorA," "myColorB," "myColorC," and "myColorD"...
tell myPage set myMSO to make multi state object with properties {name:"Spinner", geometric bounds:{72, 72, 144, 144}}
--New multistate objects contain two states when they're created. Add two more.
tell myMSO set name of state 1 to "Up" set name of state 2 to "Right" make state with properties {name:"Down"} make state with properties {name:"Left"} end tell
--Add page items to the states.
tell state 1 of myMSO set myPolygon to make polygon with properties {fill color:myColorA, stroke color:"None"} set entire path of path 1 of myPolygon to {{72, 144}, {144, 144}, {108, 72}} end tell tell state 2 of myMSO
C
HAPTER
11: Creating Dynamic Documents
Creating Multistate Objects 168 set myPolygon to make polygon with properties {fill color:myColorB, stroke color:"None"} set entire path of path 1 of myPolygon to {{72, 72}, {72, 144}, {144, 108}} end tell tell state 3 of myMSO set myPolygon to make polygon with properties {fill color:myColorC, stroke color:"None"} set entire path of path 1 of myPolygon to {{72, 72}, {108, 144}, {144, 72}} end tell tell state 4 of myMSO set myPolygon to make polygon with properties {fill color:myColorD, stroke color:"None"} set entire path of path 1 of myPolygon to {{144, 72}, {72, 108}, {144, 144}} end tell end tell
Typically, you’ll control the display of the states in a multistate object using a button. The following script fragment shows how to do this (for the complete script, refer to MultiStateObjectControl).
--Given a document "myDocument" and a page "myPage" and
--four colors "myColorA," "myColorB," "myColorC," and "myColorD"...
tell myPage set myMSO to make multi state object with properties {name:"Spinner", geometric bounds:{72, 72, 144, 144}}
--New multistate objects contain two states when they're created. Add two more.
tell myMSO set name of state 1 to "Up" set name of state 2 to "Right" make state with properties {name:"Down"} make state with properties {name:"Left"} end tell
--Add page items to the states.
tell state 1 of myMSO set myPolygon to make polygon with properties {fill color:myColorA, stroke color:"None"} set entire path of path 1 of myPolygon to {{72, 144}, {144, 144}, {108, 72}} end tell tell state 2 of myMSO set myPolygon to make polygon with properties {fill color:myColorB, stroke color:"None"} set entire path of path 1 of myPolygon to {{72, 72}, {72, 144}, {144, 108}} end tell tell state 3 of myMSO set myPolygon to make polygon with properties {fill color:myColorC, stroke color:"None"} set entire path of path 1 of myPolygon to {{72, 72}, {108, 144}, {144, 72}} end tell tell state 4 of myMSO set myPolygon to make polygon with properties {fill color:myColorD, stroke color:"None"} set entire path of path 1 of myPolygon to {{144, 72}, {72, 108}, {144, 144}} end tell set myButton to make button with properties {geometric bounds:{72, 72, 144, 144}} tell myButton set myRolloverState to make state set myClickState to make state set myNextStateBehavior to make goto next state behavior with properties {associated multi state object:myMSO, behavior event:mouse down, enable behavior:true, loops to next or previous:true} end tell
Download
Annonce