added new button syntax
[swftools.git] / doc / fileformat.sc
1 # ===========================================================================
2 #
3 # swfc(1) File format specification
4 #
5 # Warning: not all of this is actually implemented yet- if there's a
6 # "TODO" behind a command, it has yet to be integrated into swfc.
7 #
8 # ===========================================================================
9
10 # File header
11 # -----------
12
13 .flash bbox=200x200 version=6 fps=50 name="spec.swf" compress
14
15 # bbox=200x200         : set bounding box to 200x200
16 # bbox=200x200:100:100 : set bounding box to (100,100)-(300,300)
17 # bbox=autocrop        : (default) - make bbox just big enough so that nothing ever get's clipped
18 #
19 # all coordinates are in pixels, not in twips. fixed point values like 1.25, 333.40 are allowed.
20 #
21 # version=6    : generate flash mx movie
22 # fps=50       : set framerate to 50 frames/second
23 # name="..."   : save result to spec.flash. (Default: input file with extension 
24 #                                          changed to .flash, or the value of the -o command line 
25 #                                          parameter if given)
26
27 # inherit swf movies:
28 # ---------------------
29
30 .swf mymovie1 "choo1.swf"
31 .swf mymovie2 filename="choo1.swf" # long form
32 .swf mymovie3 filename=choo1.swf # long form, without quotes
33 .swf mymovie4 choo1.swf # short form, without quotes
34
35 # Notice: An embedded animation can't have a different framerate than
36 # the frame rate from the surrounding animation.
37
38 #TODO: Those files currently come from the current directory- they should come from the script directory.
39
40 # load an image:
41 # --------------
42
43 .jpeg background "panorama.jpg"
44 .jpeg background2 "panorama.jpg" quality=30% #reduces jpeg quality
45
46 .png background3 "choochoo.png" #TODO
47
48 # (you can put this directly (generating a shape), or insert it into a shape via the fill= argument
49
50 # define a texture from an image:
51 # -------------------------------
52
53 .texture text1=background scale=50% rotate=45
54
55 # define a gradient
56 # -----------------
57
58 .gradient mygradient:
59     0% red
60     50% green
61     75% aquamarine
62     100% #ffffff
63 .end
64
65 # Create simple objects:
66 # ----------------------
67
68 .box mybox1 width=100 height=50 color=black fill=none #unfilled rectangle (just the lines)
69 .box mybox2 width=100 height=50 color=black           #same as above
70 .box mybox3 width=100 height=50 color=black fill      #filled black rectangle
71 .box mybox4 width=100 height=50 color=red line=2 fill=blue #blue rectangle with red edges
72 .box mybox5 width=100 height=50 color=red line=2 fill=background #part the background image, with red edges
73
74 .circle mycircle1 r=50 color=#aa33ff fill=mygradient # filled with gradient (defined above)
75
76 # Sounds:
77 # -------
78
79 .sound sound1 "LocoStart.wav"
80
81 .frame 16
82     .play sound1 loop=1 #other arguments supported: nomultiple (don't start if already playing)
83 .frame 55
84     .stop sound1
85
86 .frame 66
87     # this starts a synchronized soundtrack at this frame position. The command
88     # expects a filename, not a sound object, as it would be duplicating the
89     # sound object otherwise, and I'd rather have that done explicitly.
90     .soundtrack "LocoStart.wav" # TODO
91
92 # Sound effects on user pressing or releasing a button 
93
94 .button mybutton shape=obj1 # TODO
95     .buttonsound press=sound1 release=sound2 enter=sound3 leave=sound4 # TODO
96 .end
97
98 # Elements of the movie should be animated by various means 
99 # moving (x,y and zoom) 
100 # ---------------------
101
102 .box obj1 width=200.0 height=100.0
103
104 .frame 100
105     .put obj1 x=0 y=0 #object starts at (0,0)
106
107 .frame 140
108     .change obj1 x+=100 y=0 scale=120% # smoothly move obj1 100 pixels to the right over 40 frames,
109                                        # scaling it to 120% of it's original size
110 .frame 170
111     .jump obj1 x=200 y=200 # make object to suddenly change to 200,200 at frame 70.
112
113 .frame 190
114     .qchange obj1 x=300 y=200 # TODO # make obj1 move towards 300,200...
115 .frame 210
116     .qchange obj1 x=300 y=300 # TODO # ... and then smoothly over to 300,300 using bspline interpolation
117
118 #.frame 220   #TODO
119 #    .jump obj1 x=reset y=reset
120
121 .frame 230
122     .del obj1   #Remove object again
123
124 # morphing
125 # --------
126
127 .morphshape morphthing start="start.fig" end="end.fig" #TODO
128 .frame 250
129     .put morphthing ratio=0%
130 .frame 270
131     .change morphthing ratio=100%
132
133 # interpolation between crude manual animation frames
134 # ---------------------------------------------------
135
136 .circle ball r=50 color=blue fill=violet
137
138 # now draw two balls, which fly around each other.
139
140 .frame 300
141 .put myball1=ball x=0 y=100 blue=0
142 .put myball2=ball x=100 y=100 red=0
143
144 .frame 310
145 # the .qchange means, "interpolate to this position and frame, using quadratic splines".
146          .qchange myball1 x=50 y=0 #TODO
147          .qchange myball2 x=50 y=100 #TODO
148
149 .frame 320
150 # We could also use coordinates relative to start position: .change myball1 x+=100 y+=0
151          .qchange myball1 x=100 y=100 #TODO
152          .qchange myball2 x=0 y=100 #TODO
153
154 .frame 330
155          .qchange myball1 x=50 y=100 #TODO
156          .qchange myball2 x=50 y=0 #TODO
157  
158 .frame 340
159 # Hmmm. This frame is the same as frame 0. How to prevent duplicating that one?
160          .qchange myball1 x=0 y=100 #TODO
161          .qchange myball2 x=100 y=100 #TODO
162
163 # color transforms (fading)
164 # -------------------------
165
166 # .put, .change, .qchange, .jump all support params which result in color transform.
167 # Everything up to the + is multiplicated, the rest summed.
168
169 .put obj1 blue=50% #(scale blue color component to 50%)
170 .change obj1 blue=128 #(same as above)
171 .change obj1 red=+25% #(shift blue color component by 25%)
172 .change obj1 red=+64 #(same as above)
173 .change obj1 green=50%+50% #(scale green color component to 50% and then shift it by 50%)
174 .change obj1 green=128+128 #(same as above)
175 .change obj1 green=-1+255 #(invert green color component)
176 .change obj1 green=2-128  #(reduce spectrum for green to the upper 50%)
177 .change obj1 luminance=50% #(fade all color components 50% to black, same as red=50% green=50% blue=50%)
178 .change obj1 alpha=50% #(make object 50% transparent)
179
180 # scaling
181 # -------
182
183 .change obj1 scale=50%   # change an object to 50% of it's size
184 .change obj1 scaley=50%  # flatten object to 50% of it's height
185 .change obj1 scaley=110% scalex=75% #(funhouse mirror!)
186
187 # rotating
188 # --------
189
190 .change obj1 rotate=45  # tilt object, counterclockwise
191
192 # shearing
193 # --------
194
195 .change obj1 shear=100%  # shear object
196
197 # sprites (a.k.a. movieClips)
198 # -------
199
200 .sprite spr1
201     .frame 1    .put ball1=ball 0 0
202     .frame 2    .change ball1 100 100
203 .end
204
205 .sprite spr2
206     .frame 1    .put ball2=ball 100 0
207     .frame 7    .change ball2 0 100
208 .end
209
210 .frame 400
211     .put spr1
212     .put spr2
213
214 # so spr1 has three frames, spr2 has seven. The whole animation loops after 21 frames.
215
216 # multi-level nesting: (sprites can be nested to any depth)
217
218 .sprite mspr1
219     .sprite mspr2
220         .sprite spr3
221         .put ball 100 0
222         .end
223     .end
224 .end
225
226 # clipping an animation inside a star-shaped sprite:
227
228 .swf mystar1 "star.swf"
229 .swf anim1 "penguins.swf"
230
231 .sprite cspr1
232     .startclip mystar1
233         .put anim1
234     .end
235 .end
236 .frame 401
237     .put cspr1 rotate=0
238 .frame 402
239     .change cspr1 rotate=360
240
241 # buttons
242 # -------
243
244 .png play "Play.png" #TODO
245 .png play_pressed "Play_pressed.png" #TODO
246 .png stoplogo "Stop.png" #TODO
247
248 .button playbutton shape=play press=play_pressed #TODO
249 .end
250
251 .button playbutton2 shape=play press=play_pressed
252     .on_press inside
253     .on_press outside
254     .on_release inside
255     .on_release outside
256     .on_move_in pressed
257     .on_move_out pressed
258     .on_move_in
259     .on_move_out
260     .on_key "a":
261         # actionscript...
262     .end
263 .end
264
265 # button which is blue, get's green when the mouse hovers over it, and
266 # white when it is pressed:
267 .button b1 shape=blueshape over=greenshape press=whiteshape #TODO
268 .end
269
270 # button where the button position is not identical to the active area:
271 .button b2 area=activearea shape=blueshape over=greenshape press=whiteshape #TODO
272 .end
273
274 # (if area is not set, it's the same as shape)
275
276 # the above put into use: pop up a window if the mouse cursor enters a certain
277 # area:
278 .button b3 area=activearea shape=emptyshape over=window1 press=window1 #TODO
279 .end
280
281 # button characters also support positioning and cxforming characters.
282 # to use this, we put the characters "virtually", and then use the
283 # instances in the button
284 .buttonput area1=playlogo x=300 y=400 rotate=0 #TODO
285 .buttonput shape1=playlogo x=400 y=400 rotate=0 red=50% #TODO
286 .buttonput over1=playlogo x=400 y=400 rotate=30 red=50% #TODO
287 .buttonput press1=playlogo x=500 y=500 rotate=180 #TODO
288 .button mybutton1 area=area1 shape=shape1 over=over1 press=press1: #TODO
289      #[...actionscript...]
290 .end
291
292 # fonts
293 # -----
294 .font font1 "myfont.swf"
295 .font font1 "myfont.ttf"
296 .font font1 "myfont.pfa"
297
298 # text fields
299 # -----------
300 .text mytext1 font=font1 text="I am a happy little scroll message" color=blue size=100%
301
302 # edittext
303 # --------
304 #(field where the flash animation can get input from the user)
305
306 .font helvetica "helvetica-bold.swf"
307 .edittext edittext1 text="Type something here" color=blue maxlength=200 font=helvetica size=24 width=320 height=200 #TODO
308 # width/height: dimensions of the box
309 # text: The text which appears initally in the box, and can be overwritten by the user
310 # maxlength: max. length of the text the user can type
311 # color/font/size: Font appeareance
312 # variable: Name of the actionscript variable the text is stored in
313 # The following boolean options are also supported:
314 # password (show input only as stars), wordwrap, multiline, html, noselect, readonly
315
316 # actionscript
317 # ------------
318
319 .action:
320     _root.play();
321 .end
322
323 # depth control
324 # -------------------
325 # .put, .change, .qchange, .jump, .startclip take before and after parameters,
326 # which can be used to specify the depth of an object
327
328 .put o1=obj1 #TODO
329 .put o2=obj1 below=o1 x=50 #TODO
330 .frame #TODO
331 .change o1 #TODO
332 .change o2 above=o1 x=50 #TODO
333
334 # newline conventions
335 # -------------------
336
337 # All Newlines are treated as normal whitespace. Therefore, splitting
338 # commands over several lines, like
339 .put obj2=obj1 x=300
340              y=300
341              red=100%
342              green=50%
343              blue=50%
344 # is allowed.
345
346 # Furthermore, having more than one command in one line is also possible:
347
348 .frame 600  .change obj1 x+=700  .change obj2 x+=300
349 .frame 601  .change obj1 x+=500  .change obj2 x+=500
350 .frame 602  .change obj1 x+=300  .change obj2 x+=700
351
352 .end # end of first file
353