Adobe 12040118 Using Help - Page 203

Creating a window using window resource specifications, field to display

Page 203 highlights

Adobe After Effects Help Using Help Creating User Interface Elements Back 203 You can control the size of each 'step' by setting the stepdelta property. Clicking ahead of or behind the position indicator makes the position indicator jump a fixed number of values toward the point where you clicked. You can control the size of this jump by setting the jumpdelta property. You can create scrollbars with horizontal or vertical orientation; if width is greater than height, the orientation is horizontal, otherwise it is vertical. The following example creates a Scrollbar element with associated StaticText and EditText elements within a panel: d l g . s i ze Pn l = d l g . a d d ( 'p a n e l ', [ 6 0 , 2 4 0 , 3 2 0 , 3 1 5 ] , ' D i m e n s i o n s' ) ; d l g . s i ze Pn l . w i d t h S t = d l g . s i ze Pn l . a d d ( 's t a t i c tex t', [ 1 5 , 1 5 , 6 5 , 3 5 ] , 'Width:'; d l g . s i ze Pn l . w i d t h S c r l = d l g . s i ze Pn l . a d d ( 's c ro l l b a r ', [75,15,195,35],300, 300, 800); d l g . s i ze Pn l . w i d t h Et = d l g . s i ze Pn l . a d d ( 'e d i t tex t', [ 2 0 5 , 1 5 , 2 4 5 , 3 5 ] ) ; Note that the last 3 arguments to the add() method that creates the scrollbar define the values for the value, minvalue and maxvalue properties. Scrollbars are often created with an associated EditText field to display the current value of the scrollbar, and to allow setting the scrollbar's position to a specific value. Creating a window using window resource specifications A specially formatted string provides a simple and compact means of creating a window and its component elements as a resource specification. A resource specification allows you to define and configure multiple window components in one easy-to-reference script. The special string is passed as the type parameter to the Window constructor function, as follows: // create a new dialog from a resource specification var alertBuilderResource = "d ia l o g { text: 'Al er t B ox Bu i ld e r ', b ou n d s : [ 1 0 0 , 1 0 0 , 4 8 0 , 4 9 0 ] , \ m s g Pn l : Pa n e l { tex t : ' Me s s a g e s', b o u n d s : [ 2 5 , 1 5 , 3 5 5 , 1 3 0 ] , \ t i t l e S t : S t a t i c Tex t { tex t : ' A l e r t b ox t i t l e : ', \ bounds:[15,15,105,35] }, \ titl eEt: E d i tText { text: 'S a mp le Ale r t', b ou n d s : [ 1 1 5 , 1 5 , 3 1 5 , 3 5 ] } , \ msg S t: S ta ticText { text: 'A l e r t m e s s a ge : ', \ bounds:[15,65,105,85] }, \ msg Et: E d i tText { text: ' ', \ bounds:[115,45,315,105], properties:{multiline:true} } \ }, \ hasBt nsCb: Checkbox { text:'Has aler t buttons?', alig nment:'center', \ bounds:[125,145,255,165] }, \ aler tB t n sPn l : Pa n el { text: 'Bu tton a li g n m e n t', b ou n d s : [ 4 5 , 1 8 0 , 3 3 5 , 2 2 5 ] , \ a l ig n LeftR b: R a d io Bu tton { tex t: ' Le f t', b ou n d s : [ 1 5 , 1 5 , 9 5 , 3 5 ] } , \ alig nCenterRb:RadioButton { text:'Center', \ bounds:[105,15,185,35] }, \ a l ig n R ig htR b: R a d io Bu tton { tex t : ' R i g h t', b ou n d s : [ 1 9 5 , 1 5 , 2 7 5 , 3 5 ] } \ }, \ si zePn l : Pa n el { text: 'D i men sio n s', b ou n d s : [ 6 0 , 2 4 0 , 3 2 0 , 3 1 5 ] , \ w i d t h S t : S t a t i c Tex t { tex t : ' Wi d t h : ', b o u n d s : [ 1 5 , 1 5 , 6 5 , 3 5 ] } , \ widthScrl:Scrollbar { minvalue:300, maxvalue:800, \ bounds:[75,15,195,35] }, \ w i d t h Et : E d i t Tex t { b o u n d s : [ 2 0 5 , 1 5 , 2 4 5 , 3 5 ] } , \ h e i g h t S t : S t a t i c Tex t { tex t : ' He i g h t : ', b o u n d s : [ 1 5 , 4 5 , 6 5 , 6 5 ] } , \ heightScrl:Scrollbar { minvalue:200, maxvalue:600, \ bounds:[75,45,195,65] }, \ hei g htEt: E d itText { bo u n d s: [2 05 , 4 5 , 2 4 5 , 6 5 ] } \ }, \ b t n Pn l : Pa n e l { tex t : ' Bu i l d i t', b o u n d s : [ 1 5 , 3 3 0 , 3 6 5 , 3 7 5 ] , \ testB t n : Bu tton { text: 'Test', b ou n d s : [ 1 5 , 1 5 , 1 1 5 , 3 5 ] } , \ buildBt n:Button { text:'Build', bounds:[125,15,225,35], \ properties:{name:'ok'} }, \ Using Help Back 203

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 189
  • 190
  • 191
  • 192
  • 193
  • 194
  • 195
  • 196
  • 197
  • 198
  • 199
  • 200
  • 201
  • 202
  • 203
  • 204
  • 205
  • 206
  • 207
  • 208
  • 209
  • 210
  • 211
  • 212
  • 213
  • 214
  • 215
  • 216
  • 217
  • 218
  • 219
  • 220
  • 221
  • 222
  • 223
  • 224
  • 225
  • 226
  • 227
  • 228
  • 229
  • 230
  • 231
  • 232
  • 233
  • 234
  • 235
  • 236
  • 237
  • 238
  • 239
  • 240
  • 241
  • 242
  • 243
  • 244
  • 245
  • 246
  • 247
  • 248
  • 249
  • 250
  • 251
  • 252
  • 253

U
sing H
elp
B
ack
203
Adobe After Effects Help
Creating User Interface Elements
U
sing H
elp
B
ack
203
You can control the size of each ‘step’ by setting the
stepdelta
property. Clicking ahead of or behind the position
indicator makes the position indicator jump a fixed number of values toward the point where you clicked. You
can control the size of this jump by setting the
jumpdelta
property.
You can create scrollbars with horizontal or vertical orientation; if width is greater than height, the orientation
is horizontal, otherwise it is vertical. The following example creates a
Scrollbar
element with associated
StaticText
and
EditText
elements within a panel:
dlg.sizePnl = dlg.add(‘panel’, [60,240,320,315], ‘Dimensions’);
dlg.sizePnl.widthSt = dlg.sizePnl.add(‘statictext’, [15,15,65,35],
‘Width:’;
dlg.sizePnl.widthScrl = dlg.sizePnl.add(‘scrollbar’,
[75,15,195,35],300, 300, 800);
dlg.sizePnl.widthEt = dlg.sizePnl.add(‘edittext’, [205,15,245,35]);
Note that the last 3 arguments to the
add
() method that creates the scrollbar define the values for the
value
,
minvalue
and
maxvalue
properties.
Scrollbars
are often created with an associated
EditText
field to display the
current value of the scrollbar, and to allow setting the scrollbar’s position to a specific value.
Creating a window using window resource specifications
A specially formatted string provides a simple and compact means of creating a window and its component
elements as a
resource specification
. A resource specification allows you to define and configure multiple
window components in one easy-to-reference script.
The special string is passed as the type parameter to the
Window
constructor function, as follows:
// create a new dialog from a resource specification
var alertBuilderResource =
“dialog { text: ‘Alert Box Builder’, bounds:[100,100,480,490], \
msgPnl: Panel { text: ‘Messages’, bounds:[25,15,355,130], \
titleSt:StaticText { text:’Alert box title:’, \
bounds:[15,15,105,35] }, \
titleEt:EditText { text:’Sample Alert’, bounds:[115,15,315,35] }, \
msgSt:
StaticText { text:’Alert message:’, \
bounds:[15,65,105,85] }, \
msgEt:
EditText { text:’<your message here>’, \
bounds:[115,45,315,105], properties:{multiline:true} } \
}, \
hasBtnsCb: Checkbox { text:’Has alert buttons?’, alignment:’center’, \
bounds:[125,145,255,165] }, \
alertBtnsPnl: Panel { text:‘Button alignment’, bounds:[45,180,335,225], \
alignLeftRb:RadioButton { text:’Left’, bounds:[15,15,95,35] }, \
alignCenterRb:RadioButton { text:’Center’, \
bounds:[105,15,185,35] }, \
alignRightRb:RadioButton { text:’Right’, bounds:[195,15,275,35] } \
}, \
sizePnl: Panel { text: ‘Dimensions’, bounds:[60,240,320,315], \
widthSt:StaticText { text:’Width:’, bounds:[15,15,65,35] }, \
widthScrl:Scrollbar { minvalue:300, maxvalue:800, \
bounds:[75,15,195,35] }, \
widthEt:EditText { bounds:[205,15,245,35] }, \
heightSt:StaticText { text:’Height:’, bounds:[15,45,65,65] }, \
heightScrl:Scrollbar { minvalue:200, maxvalue:600, \
bounds:[75,45,195,65] }, \
heightEt:EditText { bounds:[205,45,245,65] } \
}, \
btnPnl: Panel { text: ‘Build it’, bounds:[15,330,365,375], \
testBtn:Button { text:’Test’, bounds:[15,15,115,35] }, \
buildBtn:Button { text:’Build’, bounds:[125,15,225,35], \
properties:{name:’ok’} }, \