1 # ==================================================================================
3 # swfc(1) File format specification (well, sort of)
6 # ==================================================================================
8 # Notice that the following is actually a valid .sc file, generating the four swfs
9 # spec.flash, scroll1.flash, scroll2.flash and simple_viewer.flash. (Provided all included
15 .flash bbox=200x200 version=6 fps=50 name="spec.swf" compress
17 # bbox=200x200 : set bounding box to 200x200
18 # bbox=200x200:100:100 : set bounding box to (100,100)-(300,300)
19 # bbox=autocrop : (default) - make bbox just big enough so that nothing ever get's clipped
21 # all coordinates are in pixels, not in twips. fixed point values like 1.25, 333.40 are allowed.
23 # version=6 : generate flash mx movie
24 # fps=50 : set framerate to 50 frames/second
25 # name="..." : save result to spec.flash. (Default: input file with extension
26 # changed to .flash, or the value of the -o command line
29 # load a simple object:
30 # ---------------------
32 .swf myshape1 "choo1.swf"
33 .swf myshape2 filename="choo1.swf" # long form
34 .swf myshape3 filename=choo1.swf # long form, without quotes
35 .swf myshape4 choo1.swf # short form, without quotes
37 #TODO: Do those files come from the current directory, the script directory or both?
42 .jpeg background "panorama.jpg"
43 .jpeg background2 "panorama.jpg" quality=30% #reduces jpeg quality
45 .png background3 "choochoo.png"
47 # (you can put this directly (generating a shape), or insert it into a shape via the fill= argument
49 # define a texture from an image:
50 # -------------------------------
52 .texture text1=background scale=50% rotate=45
57 #.gradient mygradient:
66 .movie train1 "choochoopuff.swf"
68 # Notice: An embedded animation can't have a different framerate than
69 # the frame rate from the surrounding animation.
71 # Create simple objects:
72 # ----------------------
74 # We should support some primitives to not have to load everything
76 .box mybox1 width=100 height=50 color=black fill=none #unfilled rectangle (just the lines)
77 .box mybox2 width=100 height=50 color=black #same as above
78 .box mybox3 width=100 height=50 color=black fill #filled black rectangle
79 .box mybox4 width=100 height=50 color=red line=2 fill=blue #blue rectangle with red edges
80 .box mybox5 width=100 height=50 color=red line=2 fill=background #part the background image, with red edges
81 .circle mycircle1 r=50 color=#aa33ff fill=background
82 .egon poly1 vertices=5
84 # Continuous soundtrack synched up to several frames in a row:
85 # ------------------------------------------------------------
87 # load a sound effect:
88 .sound sound1 "LocoStart.wav"
91 .play sound1 loop=1 #other arguments supported: nomultiple (don't start if already playing)
94 # this starts a synchronized soundtrack at this frame position. The command
95 # expects a filename, not a sound object, as it would be duplicating the
96 # sound object otherwise, and I'd rather have that done explicitly.
97 .soundtrack "LocoStart.wav"
98 #... TODO: should .soundtrack sounds have a name? we could support
99 # .stop for them, which would simply stop generating mp3 data
102 # unlike characters, sounds can't have multiple instances, and can't
103 # be referenced once playing. So we stop the sound, not the instance.
106 # Sound effects on user pressing or releasing a button
108 .button playbutton shape=obj1
111 .buttonsounds playbutton press=sound1 release=sound2 enter=sound3 leave=sound4
113 # Elements of the movie should be animated by various means
114 # moving (x,y and zoom)
115 # ---------------------
117 .box obj1 width=200.0 height=100.0
120 .put obj1 x=0 y=0 #object starts at (0,0)
123 .change obj1 x+=100 y=0 scale=120% # smoothly move obj1 100 pixels to the right over 40 frames,
124 # scaling it to 120% of it's original size
126 .jump obj1 x=200 y=200 # make object to suddenly change to 200,200 at frame 70.
129 .qchange obj1 x=300 y=200 # make obj1 move towards 300,200...
131 .qchange obj1 x=300 y=300 # ... and then smoothly over to 300,300 using bspline interpolation
134 # .jump obj1 x=reset y=reset
137 .del obj1 #Remove object again
139 # morphing (easy for simple polygons, hard for more complex shapes)
140 # -----------------------------------------------------------------
142 .morphshape morphthing start="start.fig" end="end.fig"
144 #.morphshape blop [V77CJQAvn3KKYD8GDb4gFgbAZ4oM2RBdhOtvEVRdpNdIJF4tQ5gh7GzxnFYNvxe7lpXVranU
145 # +v/OjhGkCoUrOq9gUj4bJj0JjioYaA+VDsZ4Wq0+XLm0MiIgJZICQbADnUpdro5N11eVS699O]
147 # the following would be more work, but may be nice:
148 .box mybox6 width=100 height=50 color=black
149 .box mybox7 width=100 height=50 color=red
150 .morphshape morphthing2 start=mybox1 end=mybox2
152 # interpolation between crude manual animation frames
153 # ---------------------------------------------------
155 .swf ball "ball.fig" #The ball should be white or violet to make the cxforms below work
157 # now draw two balls, which fly around each other.
160 .put myball1=ball x=0 y=100 blue=0
161 .put myball2=ball x=100 y=100 red=0
164 # the .qchange means, "interpolate to this position and frame, using quadratic splines".
165 .qchange myball1 x=50 y=0
166 .qchange myball2 x=50 y=100
169 # We could also use coordinates relative to start position: .change myball1 x+=100 y+=0
170 .qchange myball1 x=100 y=100
171 .qchange myball2 x=0 y=100
174 .qchange myball1 x=50 y=100
175 .qchange myball2 x=50 y=0
178 # Hmmm. This frame is the same as frame 0. How to prevent duplicating that one?
179 .qchange myball1 x=0 y=100
180 .qchange myball2 x=100 y=100
182 # fading into existence/out of existence (colour xform):
183 # ------------------------------------------------------
185 # .put, .change, .qchange, .jump all support params which result in color transform.
186 # Everything up to the + is multiplicated, the rest summed.
187 # TODO: negative values should also be allowed.
189 .put obj1 blue=50% #(scale blue color component to 50%)
190 .change obj1 blue=128 #(same as above)
191 .change obj1 red=+25% #(shift blue color component by 25%)
192 .change obj1 red=+64 #(same as above)
193 .change obj1 green=50%+50% #(scale green color component to 50% and then shift it by 50%)
194 .change obj1 green=128+128 #(same as above)
195 .change obj1 green=-1+255 #(invert green color component)
196 .change obj1 green=2-128 #(reduce spectrum for green to the upper 50%)
197 .change obj1 luminance=50% #(fade all color components 50% to black, same as red=50% green=50% blue=50%)
198 .change obj1 alpha=50% #(make object 50% transparent)
203 .change obj1 scale=50% # change an object to 50% of it's size
204 .change obj1 scaley=50% # flatten object to 50% of it's height
205 .change obj1 scaley=110% scalex=75% #(funhouse mirror!)
210 .change obj1 rotate=45 # tilt object, counterclockwise
212 # TODO: we still don't have full control over the 2x3 object-placement matrix.
213 # (As we only have one parameter for the two values on the primary diagonal) ActionScript
214 # has the same problem, however.
222 .frame 1 .put ball1=ball 0 0
223 .frame 2 .change ball1 100 100
227 .frame 1 .put ball2=ball 100 0
228 .frame 7 .change ball2 0 100
235 # so spr1 has three frames, spr2 has seven. The whole animation loops after 21 frames.
237 # multi-level nesting: (sprites can be nested to any depth)
247 # clipping an animation inside a star-shaped sprite:
249 .swf mystar1 "star.swf"
250 .movie anim1 "penguins.swf"
260 .change cspr1 rotate=360
265 # create at minimum a Play button and a Stop button, maybe a Rewind also
266 .png playlogo "Play.png"
267 .png stoplogo "Stop.png"
269 .button myplaybutton shape=playlogo
270 #everything till the .end is actionscript.
274 .button mystopbutton shape=stoplogo
279 .put myplaybutton x=100 y=100
280 .put mystopbutton x=200 y=100
282 # The following examples drop the .end command. This is only possible
283 # if we keep the leading dot (.) in the command names. (Due to naming
284 # conflicts with Actionscript)
286 # button which is blue, get's green when the mouse hovers over it, and
287 # white when it is pressed:
289 .button b1 shape=blueshape over=greenshape press=whiteshape
291 # button where the button position is not identical to the active area:
293 .button b2 area=activearea shape=blueshape over=greenshape press=whiteshape
295 # (if area is not set, it's the same as shape)
297 # the above put into use: pop up a window if the mouse cursor enters a certain
300 .button b3 area=activearea shape=emptyshape over=window1 press=window1
302 # button characters also support positioning and cxforming characters.
303 # to use this, we put the characters "virtually", and then use the
304 # instances in the button
306 .buttonput area1=playlogo x=300 y=400 rotate=0
307 .buttonput shape1=playlogo x=400 y=400 rotate=0 red=50%
308 .buttonput over1=playlogo x=400 y=400 rotate=30 red=50%
309 .buttonput press1=playlogo x=500 y=500 rotate=180
310 .button mybutton1 area=area1 shape=shape1 over=over1 press=press1
311 #[...actionscript...]
317 #only supported via other tools (lib/examples/makefonts) at the moment.
319 .font font1 "myfont.swf"
324 #(these are scalable vector objects just like shapes)
325 .text mytext1 "I am a happy little scroll message" color=blue size=100% font=font1
331 #(field where the flash animation can get input from the user)
333 .font helvetica "helvetica-bold.swf"
334 .edittext edittext1 text="Type something here" color=blue maxlength=200 font=helvetica size=24 width=320 height=200
335 # width/height: dimensions of the box
336 # text: The text which appears initally in the box, and can be overwritten by the user
337 # maxlength: max. length of the text the user can type
338 # color/font/size: Font appeareance
339 # variable: Name of the actionscript variable the text is stored in
340 # The following boolean options are also supported:
341 # password (show input only as stars), wordwrap, multiline, html, noselect, readonly
350 setproperty spr1._visible 1 #TODO: spr1._visible=1?
368 .button playbutton2 shape=obj1 opcodes
375 .button playbutton3 shape=obj1 opcodes
384 # todo: mx initaction, placeobject2 initclip
387 # -------------------
389 # .put, .change, .qchange, .jump, .startclip take before and after parameters,
390 # which can be used to specify the depth of an object
393 .put o2=obj1 below=o1 x=50
396 .change o2 above=o1 x=50
398 # newline conventions
399 # -------------------
401 # All Newlines are treated as normal whitespace. Therefore, splitting
402 # commands over several lines, like
410 # Furthermore, having more than one command in one line is also possible:
412 .frame 600 .change obj1 x+=700 .change obj2 x+=300
413 .frame 601 .change obj1 x+=500 .change obj2 x+=500
414 .frame 602 .change obj1 x+=300 .change obj2 x+=700
416 .end # end of first file
418 # ==================================================================================
420 # Ok, now for some actual examples
422 # ==================================================================================
426 # This example scrolls a single line of text from the bottom to the top, with
430 .flash bbox=200x200 fps=25 version=6 name="scroll1.swf"
432 .jpeg background "panorama.jpg"
434 .font helvetica-bold "helvetica-bold.swf"
435 .text title1 "I am a happy little scroll message" color=blue font=helvetica-bold size=100%
437 .put background x=0 y=0
440 .put obj1=title1 x=0 y=200 # As text box positions are specified at the upper left corner, this
441 # places the text just below the bottom.
442 # (.put title1 is actually .put title1=title1 (i.e. the instance has the same name as the character)
446 # "change" moves the object to the new position, _interpolating_ in the frames between.
447 # Do we also need a command for abruptly changing position (omitting interpolation)?
449 .change obj1 x=0 y-=12 # Now move the text up until it disappears at the top, in 40 frames
451 # to scroll horizontally, we would have modified the x instead of the y coordinate, and scrolled to -200
452 # (assuming the text is < 200 pixels)
456 # ==================================================================================
460 # This example now also fades the text in and out again
463 .flash bbox=200x200 fps=25 version=6 name="scroll2.swf"
464 .jpeg background "panorama.jpg"
466 #create some text for a title and credits
468 .font helvetica "helvetica-bold.swf"
469 .text title1 "ChooChoo Train" color=blue font=helvetica size=100%
471 # move from bottom to top. Fade it in on the way,
472 # then fade it out again.
473 # TODO: the following looks like fading only if the background is black. Add alpha channel support.
474 .put obj1=title1 x=0 y=200 luminance=0%
476 .change obj1 luminance=100%
478 .change obj1 y-=12 luminance=0%
484 # Create the simple_viewer.flash file used in SWFTools.
486 .flash bbox=1024x768 version=4 fps=25 name="simple_viewer.swf"
488 .swf leftshape "left.fig"
489 .swf rightshape "right.fig"
496 setvariable "/subtitle" ""
499 .buttonput left=leftshape luminance=50%
500 .buttonput lefthover=leftshape luminance=75%
501 .buttonput leftpress=leftshape luminance=100%
502 .button leftbutton shape=left over=lefthover press=leftpress
504 previousframe viewport
507 .buttonput right=rightshape x=20 luminance=50%
508 .buttonput righthover=rightshape x=20 luminance=75%
509 .buttonput rightpress=rightshape x=20 luminance=100%
510 .button rightbutton shape=right over=righthover press=rightpress
515 .font arial "arial.swf"
516 .edittext subtitlebox width=826 height=160 color=black variable="/:subtitle" font=arial size=24
521 .put subtitlebox x=40
528 .flash bbox=400x300 version=4 fps=50 name="boxLayers.swf"
530 .box box1 width=100 height=100 color=white fill
531 .box box2 width=100 height=100 color=white fill
534 .put box1 x=30 y=10 blue=0 red=0 luminance=50
535 .put box2 x=60 y=40 green=0 red=0 luminance=50
537 .jump box1 above=box2
539 .jump box2 above=box1
542 # ---------------------- everything below this line should actually be working ----------------------
547 # Do things with rectangles.
549 .flash bbox=autocrop version=6 fps=50 name="boxes.swf" compress
551 .box box1 width=100 height=100 color=red fill #filled red box
552 .box box2 width=100 height=100 color=white #white hollow frame
553 .box box3 width=100 height=100 color=green line=10 fill=blue #filled blue box, with thick green border
556 .put box1 x=30 scalex=30
557 .put box2 x=30 scalex=30
558 .put box3 x=30 scalex=30
560 .change box1 x+=300 scalex=100
561 .change box2 y+=300 scalex=100
562 .change box3 x+=300 y-=300 scalex=100
572 .flash bbox=autocrop version=4 fps=50 name="monkey.swf"
574 .swf island "island.swf"
575 .swf monkey "monkey4.swf"
577 .point leftfoot 45 177
578 .point rightfoot 138 177
579 .frame 0 .put monkey 160 160
580 .frame 20 .change monkey 160 160
581 .frame 30 .change monkey 160 122
582 .frame 35 .change monkey 160 112
583 .frame 40 .change monkey 160 122
584 .frame 50 .change monkey 160 160
586 .frame 70 .change monkey 205 337 pin=leftfoot rotate=0
587 .frame 90 .change monkey rotate=30
588 .frame 100 .change monkey rotate=30
589 .frame 120 .change monkey rotate=0
590 .frame 122 .change monkey 298 337 pin=rightfoot rotate=0
591 .frame 140 .change monkey rotate=-30
592 .frame 150 .change monkey rotate=-30
593 .frame 170 .change monkey rotate=0
598 # Try color transforms
600 .flash name="cxform.swf" version=5
604 .put s1 x=50 y=50 scalex=110 scaley=110
606 .change s1 x=0 y=0 scalex=210 scaley=210 red=-1+255 green=-1+255 blue=-1+255 #invert
608 .change s1 x=100 y=50 scalex=110 scaley=110 red=0 green=+0 blue=+0 #remove red
610 .change s1 x=0 y=0 scalex=210 scaley=210 red=+0 green=2 blue=-1+255 #amplify green, invert blue
612 .change s1 x=50 y=100 scalex=110 scaley=110 red=2-128 green=-2+255 blue=+0.7+40 #alien glow
614 .change s1 x=0 y=0 scalex=210 scaley=210 red=8-1024 green=8-1024 blue=8-1024 #palette reduce
616 .change s1 x=0 y=0 scalex=210 scaley=210 red=+0 green=+0 blue=+0 #back to normal
618 .change s1 x=105 y=105 scalex=0 scaley=0 luminance=0 #fadeout
625 .flash bbox=200x200 version=5 fps=25 name="transparency.swf"
627 .box box1 90 90 color=yellow fill=blue line=5
628 .box box2 90 90 color=white fill=red line=5
630 .put b1=box1 75 75 rotate=0
631 .put b2=box1 75 75 rotate=90
632 .put b3=box1 75 75 rotate=180
633 .put b4=box1 75 75 rotate=270
634 .put box2 30 30 alpha=100%
636 .change b1 rotate+=360
637 .change b2 rotate+=360
638 .change b3 rotate+=360
639 .change b4 rotate+=360
640 .change box2 alpha=0%
646 # Test points, pivots, pins
648 .flash version=5 fps=20 name="points.swf"
650 .box box 90 90 color=white fill=red line=5
657 .put b1a=box x=90 y=90 pin=center
658 .put b1b=box x=90 y=90 pin=center alpha=50%
659 # OR: .put b1=box x=90 y=90 pin=(45,45) rotate=0
661 .put b2=box x=90 y=90 pin=corner1 alpha=75% blue=+128 red=0.2
662 .put b3=box x=90 y=90 pin=corner2 alpha=75% blue=+128 red=0.2
663 .put b4=box x=90 y=90 pin=corner3 alpha=75% blue=+128 red=0.2
664 .put b5=box x=90 y=90 pin=corner4 alpha=75% blue=+128 red=0.2
667 .change b1a rotate-=720
668 .change b1b rotate+=720
669 .change b2 rotate+=360
670 .change b3 rotate-=360
671 .change b4 rotate+=360
672 .change b5 rotate-=360
680 .flash name="clip.swf" fps=25
681 .sprite s1 # this just constructs a colorful object "s1"
682 .box b1 40 40 color=red fill=violet line=10
683 .box b2 40 40 color=blue fill=green line=10
684 .box b3 40 40 color=yellow fill=cyan line=10
685 .box b4 40 40 color=white fill=black line=10
692 # the line and fill colors of the circle don't actually do anything-
693 # as it's used for clipping only it's shape matters
694 .circle c1 80 color=blue fill=green
696 .startclip c1 x=-160 y=-160 #c1 clips...
697 .put s1 # ...the sprite s1
701 .change c1 x=160 y=160 # movement doesn't change the clipping property
710 .flash name="fonts.swf"
711 .font courier "Courier.swf"
712 .font helvetica "Helvetica.swf"
713 .text abc text="abcdefghijklmnopqrstuvwxyz" font=courier size=100% color=blue
714 .text abc2 text="abcdefghijklmnopqrstuvwxyz" font=helvetica size=100% color=red
724 .flash bbox=300x200:-30 name="shear.swf" fps=25
725 .font helvetica "Helvetica.swf"
726 .text text text="Shear" font=helvetica size=100% color=yellow
727 .put t0=text y=150 alpha=0% shear=0
728 .put t1=text y=150 alpha=0% shear=1
729 .put t2=text y=150 alpha=0% shear=2
730 .put t3=text y=150 alpha=0% shear=3
731 .put t4=text y=150 alpha=0% shear=4
732 .put t5=text y=150 alpha=0% shear=5
733 .put t6=text y=150 alpha=0% shear=6
734 .put t7=text y=150 alpha=0% shear=7
735 .put t8=text y=150 alpha=0% shear=8
736 .put t9=text y=150 alpha=0% shear=9
738 .change t0 alpha=40% shear=0
739 .change t1 alpha=40% shear=0
740 .change t2 alpha=40% shear=0
741 .change t3 alpha=40% shear=0
742 .change t4 alpha=40% shear=0
743 .change t5 alpha=40% shear=0
744 .change t6 alpha=40% shear=0
745 .change t7 alpha=40% shear=0
746 .change t8 alpha=40% shear=0
747 .change t9 alpha=40% shear=0
749 .change t0 .change t1 .change t2 .change t3 .change t4
750 .change t5 .change t6 .change t7 .change t8 .change t9
752 .change t0 alpha=0% shear=-9
753 .change t1 alpha=0% shear=-8
754 .change t2 alpha=0% shear=-7
755 .change t3 alpha=0% shear=-6
756 .change t4 alpha=0% shear=-5
757 .change t5 alpha=0% shear=-4
758 .change t6 alpha=0% shear=-3
759 .change t7 alpha=0% shear=-2
760 .change t8 alpha=0% shear=-1
761 .change t9 alpha=0% shear=-0
768 .flash name="sound.swf" fps=25
769 .sound loco "LocoStart.wav"
770 .sound whistle "Whistle.wav"
776 .play whistle loop=20