3 Creates the swf file keyboard_viewer.swf.
4 This can be used to navigate through frames using the keyboard (space,
5 cursor left, cursor right)
6 Notice that the movie has to clicked with the mouse once to get
7 navigation activated in most browsers.
9 Part of the swftools package.
11 Copyright (c) 2000, 2001 Matthias Kramm <kramm@quiss.org>
13 This file is distributed under the GPL, see file COPYING for details
25 int main (int argc,char ** argv)
31 ActionTAG*a1,*a2,*a3,*a4,*a5;
32 S32 width=1024,height = 768;
36 memset(&swf,0x00,sizeof(SWF)); // set global movie parameters
38 swf.fileVersion = 4; // make flash 4 compatible swf
39 swf.frameRate = 0x1900; // about 0x19 frames per second
41 swf.movieSize.xmax = 20*width; // flash units: 1 pixel = 20 units
42 swf.movieSize.ymax = 20*height;
44 swf.firstTag = swf_InsertTag(NULL,ST_SETBACKGROUNDCOLOR);
59 /* the "viewport" object will be replaced by swfcombine
60 with the object to browse. It is placed at the
61 upper left corner (0,0), by setting m.tx and m.ty
62 to 0. Therefore, the buttons are "in" the viewport,
64 tag = swf_InsertTag(tag,ST_DEFINESPRITE);
65 swf_SetU16(tag, 23); //id
66 swf_SetU16(tag, 0); //frames
67 tag = swf_InsertTag(tag,ST_END);
68 tag = swf_InsertTag(tag,ST_PLACEOBJECT2);
71 swf_ObjectPlace(tag, 23, 1,&m,0,"viewport");
73 a1 = action_SetTarget(0, "viewport");
74 a1 = action_PreviousFrame(a1);
75 a1 = action_SetTarget(a1, "");
78 a2 = action_SetTarget(0, "viewport");
79 a2 = action_NextFrame(a2);
80 a2 = action_SetTarget(a2,"");
84 a3 = action_SetTarget(a3,"viewport");
86 a3 = action_SetTarget(a3,"");
88 a3 = action_PushString(a3,"/:subtitle");
89 a3 = action_PushString(a3,""); //reset variable
90 a3 = action_SetVariable(a3);
94 a4 = action_GetUrl(0, "lichtfarbe.html", "_this");
97 a5 = action_GetUrl(0, "phybas.html","_this"); // load html in this window
100 tag = swf_InsertTag(tag,ST_DEFINESHAPE);
101 swf_ShapeNew(&s); // create new shape instance
102 rgb.r = rgb.b = rgb.g = 0x00;
103 ls1 = swf_ShapeAddLineStyle(s,40,&rgb);
104 fs1 = swf_ShapeAddSolidFillStyle(s,&rgb);
110 swf_SetRect(tag,&r); // set shape bounds
111 swf_SetShapeHeader(tag,s); // write all styles to tag
113 swf_ShapeSetAll(tag,s,0,0,ls1,fs1,0); // move to (0,0), select linestyle ls1 and no fillstyle
114 /* SetLine coordinates are relative.
115 It's important that the start and end points match, otherwise
116 the Macromedia Flash player will crash. */
117 swf_ShapeSetLine(tag,s,20*width,0*height);
118 swf_ShapeSetLine(tag,s,0*width,20*height);
119 swf_ShapeSetLine(tag,s,-20*width,0*height);
120 swf_ShapeSetLine(tag,s,0*width,-20*height);
122 swf_ShapeSetEnd(tag); // finish drawing
123 swf_ShapeFree(s); // clean shape structure (which isn't needed anymore after writing the tag)
125 tag = swf_InsertTag(tag,ST_DEFINEBUTTON2);
126 swf_SetU16(tag,30); //id
127 swf_ButtonSetFlags(tag, 0); //menu=no
128 swf_ButtonSetRecord(tag,BS_HIT,77,1,NULL,NULL);
129 swf_SetU8(tag,0); // end of button records
131 swf_ButtonSetCondition(tag, BC_CURSORLEFT);
132 swf_ActionSet(tag,a1);
133 swf_ButtonSetCondition(tag, BC_CURSORRIGHT);
134 swf_ActionSet(tag,a2);
135 swf_ButtonSetCondition(tag, BC_SPACE);
136 swf_ActionSet(tag,a2);
137 swf_ButtonSetCondition(tag, BC_ESCAPE);
138 swf_ActionSet(tag,a4);
139 swf_ButtonSetCondition(tag, BC_ENTER);
140 swf_ActionSet(tag,a5);
142 swf_ButtonPostProcess(tag, 5); // don't forget!
145 tag = swf_InsertTag(tag,ST_DOACTION);
146 swf_ActionSet(tag,a3);
150 tag = swf_InsertTag(tag,ST_PLACEOBJECT2);
151 swf_ObjectPlace(tag, 30, 2,&m,0,0);
162 tag = swf_InsertTag(tag,ST_DEFINEFONT2); {
163 U8 data[] = {0x90, 0x00, 0x0f, 0x54, 0x69, 0x6d, 0x65, 0x73,
164 0x20, 0x4e, 0x65, 0x77, 0x20, 0x52, 0x6f, 0x6d,
165 0x61, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
166 0x00, 0x00, 0x00, 0x00};
167 swf_SetU16(tag, 0x76); //id
168 swf_SetBlock(tag, data, sizeof(data));
170 tag = swf_InsertTag(tag,ST_DEFINEEDITTEXT); {
171 EditTextLayout layout;
173 layout.leftmargin = 0;
174 layout.rightmargin = 0;
178 swf_SetU16(tag, 0x77);//id
180 r.xmax = r.xmin+ 826*20;
183 rgb.r = rgb.g = rgb.b = 0;
185 swf_SetEditText(tag, ET_MULTILINE|ET_READONLY, r, 0, &rgb, 0, 0x76, 20*40, &layout, "/:subtitle");
188 tag = swf_InsertTag(tag,ST_PLACEOBJECT2);
189 swf_ObjectPlace(tag, 0x77, 4,&m,0,0);
192 tag = swf_InsertTag(tag,ST_SHOWFRAME);
193 tag = swf_InsertTag(tag,ST_END);
195 f = open("keyboard_viewer.swf",O_WRONLY|O_CREAT|O_TRUNC, 0644);
196 if FAILED(swf_WriteSWF(f,&swf)) fprintf(stderr,"WriteSWF() failed.\n");
199 swf_FreeTags(&swf); // cleanup