Adobe 65007312 Programming Guide - Page 126

Creating the Flash movie, Lightroom takes a screenshot of the Flash movie - flash 10

Page 126 highlights

CHAPTER 6: Writing a Web-engine Plug-in Defining the data model 126 Creating the Flash movie Your web-engine folder must include a simple Flash movie that renders the "iconic" representation of each web page. The ActionScript file that defines your movie can access the global variables provided by the flashvar entry in iconicPreview, at the top level of the _root object. Your Flash movie should do these things: 1. Set the stage behavior: Stage.scaleMode = "noScale"; Stage.align = "tl"; This ensures that your preview renders without stretching or distortion. 2. Create an external interface callback called ready, which Lightroom will poll waiting for your preview to finish drawing: _root.ready = 'no'; _root.readyFunc = function(str:String) { return _root.ready; } ExternalInterface.addCallback("ready", _root, _root.readyFunc); Then at a later time (usually in a subsequent frame): _root.ready = 'yes'; Once your ready function returns "yes", Lightroom takes a screenshot of the Flash movie and terminates its execution (in order to reduce CPU usage) 3. Initialize default values, so that you can preview your movie without running it in Lightroom. var numCols; if( _root.numCols != null ) { numCols =parseInt( _root.numCols ); } else { // default value numCols = 4; } Do this for each model property you are using in your preview. 4. Draw the preview. This can be done by rearranging existing objects that you created in Flash, or simply by using the drawing primitives of the ActionScript programming language. For example: var cellSize = 10; for( x = 0; x < numCols; x++ ) { _root.beginFill( cellColor, 100 ); _root.moveTo(x*cellSize, y* cellSize ); _root.lineTo( (x+1)* cellSize, y* cellSize ); _root.lineTo( (x+1)* cellSize, (y+1)* cellSize ); _root.lineTo( x* cellSize,+ (y+1)* cellSize ); _root.endFill(); } This draws as many rectangle as are specified in the numCols Flash variable.

  • 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

C
HAPTER
6: Writing a Web-engine Plug-in
Defining the data model
126
Creating the Flash movie
Your web-engine folder must include a simple Flash movie that renders the "iconic" representation of each
web page. The ActionScript file that defines your movie can access the global variables provided by the
flashvar
entry in
iconicPreview
, at the top level of the
_root
object.
Your Flash movie should do these things:
1.
Set the stage behavior:
Stage.scaleMode = "noScale";
Stage.align = "tl";
This ensures that your preview renders without stretching or distortion.
2.
Create an external interface callback called
ready
, which Lightroom will poll waiting for your preview
to finish drawing:
_root.ready = 'no';
_root.readyFunc = function(str:String) {
return _root.ready;
}
ExternalInterface.addCallback("ready", _root, _root.readyFunc);
Then at a later time (usually in a subsequent frame):
_root.ready = 'yes';
Once your ready function returns
"yes"
, Lightroom takes a screenshot of the Flash movie and
terminates its execution (in order to reduce CPU usage)
3.
Initialize default values, so that you can preview your movie without running it in Lightroom.
var numCols;
if( _root.numCols != null ) {
numCols =parseInt( _root.numCols );
}
else {
// default value
numCols = 4;
}
Do this for each model property you are using in your preview.
4.
Draw the preview. This can be done by rearranging existing objects that you created in Flash, or simply
by using the drawing primitives of the ActionScript programming language. For example:
var cellSize = 10;
for( x = 0; x < numCols; x++ ) {
_root.beginFill( cellColor, 100 );
_root.moveTo(x*cellSize, y* cellSize );
_root.lineTo( (x+1)* cellSize, y* cellSize );
_root.lineTo( (x+1)* cellSize, (y+1)* cellSize );
_root.lineTo( x* cellSize,+ (y+1)* cellSize );
_root.endFill();
}
This draws as many rectangle as are specified in the
numCols
Flash variable.