3 Creates the swf file simple_viewer.swf.
4 I'm not much of an designer. Suggestions and improvements concerning
5 this file or simple_viewer.swf are highly welcome. -mk
7 Part of the swftools package.
9 Copyright (c) 2000, 2001 Matthias Kramm <kramm@quiss.org>
11 This file is distributed under the GPL, see file COPYING for details
21 int button_sizex = 20; //button size in pixels
22 int button_sizey = 20;
24 RGBA button_colors[6]=
25 {{0,0x00,0x00,0x80}, //Idle left
26 {0,0x00,0x00,0x80}, // " right
27 {0,0x20,0x20,0xc0}, //MouseOver left
28 {0,0x20,0x20,0xc0}, // " right
29 {0,0x10,0x10,0xff}, //Down left
30 {0,0x10,0x10,0xff}};// " right
32 int useDefineButton2 = 0; // set this to 1 to use DefineButton2 Tags
33 // instead of DefineButton1
36 int main (int argc,char ** argv)
43 S32 width=1024,height = 768;
49 memset(&swf,0x00,sizeof(SWF)); // set global movie parameters
51 swf.fileVersion = 4; // make flash 4 compatible swf
52 swf.frameRate = 0x1900; // about 0x19 frames per second
54 swf.movieSize.xmax = 20*width; // flash units: 1 pixel = 20 units
55 swf.movieSize.ymax = 20*height;
57 swf.firstTag = swf_InsertTag(NULL,ST_SETBACKGROUNDCOLOR);
72 /* the "viewport" object will be replaced by swfcombine
73 with the object to browse. It is placed at the
74 upper left corner (0,0), by setting m.tx and m.ty
75 to 0. Therefore, the buttons are "in" the viewport,
77 tag = swf_InsertTag(tag,ST_DEFINESPRITE);
78 swf_SetU16(tag, 23); //id
79 swf_SetU16(tag, 0); //frames
80 tag = swf_InsertTag(tag,ST_END);
81 tag = swf_InsertTag(tag,ST_PLACEOBJECT2);
84 swf_ObjectPlace(tag, 23, 1,&m,0,"viewport");
86 for(count=0;count<6;count++)
88 tag = swf_InsertTag(tag,ST_DEFINESHAPE);
89 swf_ShapeNew(&s); // create new shape instance
90 rgb.r = rgb.b = rgb.g = 0x00;
91 ls1 = swf_ShapeAddLineStyle(s,40,&rgb);
92 rgb = button_colors[count];
93 fs1 = swf_ShapeAddSolidFillStyle(s,&rgb);
94 swf_SetU16(tag,32+count); // now set character ID
99 swf_SetRect(tag,&r); // set shape bounds
100 swf_SetShapeHeader(tag,s); // write all styles to tag
103 swf_ShapeSetAll(tag,s,0,0,ls1,fs1,0); // move to (0,0), select linestyle ls1 and no fillstyle
104 /* SetLine coordinates are relative.
105 It's important that the start and end points match, otherwise
106 the Macromedia Flash player will crash. */
107 swf_ShapeSetLine(tag,s,20*button_sizex,20*button_sizey);
108 swf_ShapeSetLine(tag,s,-20*button_sizex,20*button_sizey);
109 swf_ShapeSetLine(tag,s,0,-40*button_sizey);
111 swf_ShapeSetAll(tag,s,20*button_sizex,0,ls1,fs1,0);
112 swf_ShapeSetLine(tag,s,-20*button_sizex,20*button_sizey);
113 swf_ShapeSetLine(tag,s,20*button_sizex,20*button_sizey);
114 swf_ShapeSetLine(tag,s,0,-40*button_sizey);
116 swf_ShapeSetEnd(tag); // finish drawing
117 swf_ShapeFree(s); // clean shape structure (which isn't needed anymore after writing the tag)
120 a1 = swf_ActionStart(tag);
121 action_SetTarget("viewport");
122 action_PreviousFrame();
123 action_SetTarget("");
127 a2 = swf_ActionStart(tag);
128 action_SetTarget("viewport");
130 action_SetTarget("");
134 a3 = swf_ActionStart(tag);
135 action_SetTarget("viewport");
137 action_SetTarget("");
139 action_PushString("/:subtitle");
140 action_PushString(""); //reset variable
141 action_SetVariable();
148 if(!useDefineButton2)
150 tag = swf_InsertTag(tag,ST_DEFINEBUTTON);
151 swf_SetU16(tag,30+t); //id
152 swf_ButtonSetRecord(tag,BS_UP|BS_HIT,32+t,1,NULL,NULL);
153 swf_ButtonSetRecord(tag,BS_OVER,34+t,1,NULL,NULL);
154 swf_ButtonSetRecord(tag,BS_DOWN,36+t,1,NULL,NULL);
155 swf_SetU8(tag,0); // end of button records
158 swf_ActionSet(tag,a2);
160 swf_ActionSet(tag,a1);
164 tag = swf_InsertTag(tag,ST_DEFINEBUTTON2);
165 swf_SetU16(tag,30+t); //id
166 swf_ButtonSetFlags(tag, 0); //menu=no
167 swf_ButtonSetRecord(tag,BS_UP|BS_HIT,32+t,1,NULL,NULL);
168 swf_ButtonSetRecord(tag,BS_OVER,34+t,1,NULL,NULL);
169 swf_ButtonSetRecord(tag,BS_DOWN,36+t,1,NULL,NULL);
170 swf_SetU8(tag,0); // end of button records
172 swf_ButtonSetCondition(tag, BC_OVERDOWN_OVERUP);
174 swf_ActionSet(tag,a2);
176 swf_ActionSet(tag,a1);
178 swf_ButtonPostProcess(tag, 1); // don't forget!
182 tag = swf_InsertTag(tag,ST_DOACTION);
183 swf_ActionSet(tag,a3);
187 tag = swf_InsertTag(tag,ST_PLACEOBJECT2);
188 swf_ObjectPlace(tag, 30, 2,&m,0,0);
189 m.tx = button_sizex*30;
190 tag = swf_InsertTag(tag,ST_PLACEOBJECT2);
191 swf_ObjectPlace(tag, 31, 3,&m,0,0);
198 tag = swf_InsertTag(tag,ST_DEFINEFONT2); {
199 U8 data[] = {0x90, 0x00, 0x0f, 0x54, 0x69, 0x6d, 0x65, 0x73,
200 0x20, 0x4e, 0x65, 0x77, 0x20, 0x52, 0x6f, 0x6d,
201 0x61, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
202 0x00, 0x00, 0x00, 0x00};
203 swf_SetU16(tag, 0x76); //id
204 swf_SetBlock(tag, data, sizeof(data));
206 tag = swf_InsertTag(tag,ST_DEFINEEDITTEXT); {
207 EditTextLayout layout;
209 layout.leftmargin = 0;
210 layout.rightmargin = 0;
214 swf_SetU16(tag, 0x77);//id
215 r.xmin = button_sizex*60;
216 r.xmax = r.xmin+ 826*20;
218 r.ymax = button_sizey*80;
219 rgb.r = rgb.g = rgb.b = 0;
221 swf_SetEditText(tag, ET_MULTILINE|ET_READONLY, r, 0, &rgb, 0, 0x76, button_sizey*40, &layout, "/:subtitle");
224 tag = swf_InsertTag(tag,ST_PLACEOBJECT2);
225 swf_ObjectPlace(tag, 0x77, 4,&m,0,0);
228 tag = swf_InsertTag(tag,ST_SHOWFRAME);
229 tag = swf_InsertTag(tag,ST_END);
232 f = open("simple_viewer.swf",O_WRONLY|O_CREAT|O_TRUNC, 0644);
233 if FAILED(swf_WriteSWF(f,&swf)) fprintf(stderr,"WriteSWF() failed.\n");
236 swf_FreeTags(&swf); // cleanup