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 program is free software; you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published by
15 the Free Software Foundation; either version 2 of the License, or
16 (at your option) any later version.
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License for more details.
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software
25 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
36 int main (int argc
,char ** argv
)
42 ActionTAG
*a1
,*a2
,*a3
,*a4
,*a5
;
43 S32 width
=1024,height
= 768;
47 memset(&swf
,0x00,sizeof(SWF
)); // set global movie parameters
49 swf
.fileVersion
= 4; // make flash 4 compatible swf
50 swf
.frameRate
= 0x1900; // about 0x19 frames per second
52 swf
.movieSize
.xmax
= 20*width
; // flash units: 1 pixel = 20 units
53 swf
.movieSize
.ymax
= 20*height
;
55 swf
.firstTag
= swf_InsertTag(NULL
,ST_SETBACKGROUNDCOLOR
);
70 /* the "viewport" object will be replaced by swfcombine
71 with the object to browse. It is placed at the
72 upper left corner (0,0), by setting m.tx and m.ty
73 to 0. Therefore, the buttons are "in" the viewport,
75 tag
= swf_InsertTag(tag
,ST_DEFINESPRITE
);
76 swf_SetU16(tag
, 23); //id
77 swf_SetU16(tag
, 0); //frames
78 tag
= swf_InsertTag(tag
,ST_END
);
79 tag
= swf_InsertTag(tag
,ST_PLACEOBJECT2
);
82 swf_ObjectPlace(tag
, 23, 1,&m
,0,"viewport");
84 a1
= action_SetTarget(0, "viewport");
85 a1
= action_PreviousFrame(a1
);
86 a1
= action_SetTarget(a1
, "");
89 a2
= action_SetTarget(0, "viewport");
90 a2
= action_NextFrame(a2
);
91 a2
= action_SetTarget(a2
,"");
95 a3
= action_SetTarget(a3
,"viewport");
97 a3
= action_SetTarget(a3
,"");
99 a3
= action_PushString(a3
,"/:subtitle");
100 a3
= action_PushString(a3
,""); //reset variable
101 a3
= action_SetVariable(a3
);
105 a4
= action_GetUrl(0, "lichtfarbe.html", "_this");
108 a5
= action_GetUrl(0, "phybas.html","_this"); // load html in this window
111 tag
= swf_InsertTag(tag
,ST_DEFINESHAPE
);
112 swf_ShapeNew(&s
); // create new shape instance
113 rgb
.r
= rgb
.b
= rgb
.g
= 0x00;
114 ls1
= swf_ShapeAddLineStyle(s
,40,&rgb
);
115 fs1
= swf_ShapeAddSolidFillStyle(s
,&rgb
);
121 swf_SetRect(tag
,&r
); // set shape bounds
122 swf_SetShapeHeader(tag
,s
); // write all styles to tag
124 swf_ShapeSetAll(tag
,s
,0,0,ls1
,fs1
,0); // move to (0,0), select linestyle ls1 and no fillstyle
125 /* SetLine coordinates are relative.
126 It's important that the start and end points match, otherwise
127 the Macromedia Flash player will crash. */
128 swf_ShapeSetLine(tag
,s
,20*width
,0*height
);
129 swf_ShapeSetLine(tag
,s
,0*width
,20*height
);
130 swf_ShapeSetLine(tag
,s
,-20*width
,0*height
);
131 swf_ShapeSetLine(tag
,s
,0*width
,-20*height
);
133 swf_ShapeSetEnd(tag
); // finish drawing
134 swf_ShapeFree(s
); // clean shape structure (which isn't needed anymore after writing the tag)
136 tag
= swf_InsertTag(tag
,ST_DEFINEBUTTON2
);
137 swf_SetU16(tag
,30); //id
138 swf_ButtonSetFlags(tag
, 0); //menu=no
139 swf_ButtonSetRecord(tag
,BS_HIT
,77,1,NULL
,NULL
);
140 swf_SetU8(tag
,0); // end of button records
142 swf_ButtonSetCondition(tag
, BC_CURSORLEFT
);
143 swf_ActionSet(tag
,a1
);
144 swf_ButtonSetCondition(tag
, BC_CURSORRIGHT
);
145 swf_ActionSet(tag
,a2
);
146 swf_ButtonSetCondition(tag
, BC_SPACE
);
147 swf_ActionSet(tag
,a2
);
148 swf_ButtonSetCondition(tag
, BC_ESCAPE
);
149 swf_ActionSet(tag
,a4
);
150 swf_ButtonSetCondition(tag
, BC_ENTER
);
151 swf_ActionSet(tag
,a5
);
153 swf_ButtonPostProcess(tag
, 5); // don't forget!
156 tag
= swf_InsertTag(tag
,ST_DOACTION
);
157 swf_ActionSet(tag
,a3
);
161 tag
= swf_InsertTag(tag
,ST_PLACEOBJECT2
);
162 swf_ObjectPlace(tag
, 30, 2,&m
,0,0);
173 tag
= swf_InsertTag(tag
,ST_DEFINEFONT2
); {
174 U8 data
[] = {0x90, 0x00, 0x0f, 0x54, 0x69, 0x6d, 0x65, 0x73,
175 0x20, 0x4e, 0x65, 0x77, 0x20, 0x52, 0x6f, 0x6d,
176 0x61, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
177 0x00, 0x00, 0x00, 0x00};
178 swf_SetU16(tag
, 0x76); //id
179 swf_SetBlock(tag
, data
, sizeof(data
));
181 tag
= swf_InsertTag(tag
,ST_DEFINEEDITTEXT
); {
182 EditTextLayout layout
;
184 layout
.leftmargin
= 0;
185 layout
.rightmargin
= 0;
189 swf_SetU16(tag
, 0x77);//id
191 r
.xmax
= r
.xmin
+ 826*20;
194 rgb
.r
= rgb
.g
= rgb
.b
= 0;
196 swf_SetEditText(tag
, ET_MULTILINE
|ET_READONLY
, r
, 0, &rgb
, 0, 0x76, 20*40, &layout
, "/:subtitle");
199 tag
= swf_InsertTag(tag
,ST_PLACEOBJECT2
);
200 swf_ObjectPlace(tag
, 0x77, 4,&m
,0,0);
203 tag
= swf_InsertTag(tag
,ST_SHOWFRAME
);
204 tag
= swf_InsertTag(tag
,ST_END
);
206 f
= open("keyboard_viewer.swf",O_WRONLY
|O_CREAT
|O_TRUNC
|O_BINARY
, 0644);
207 if FAILED(swf_WriteSWF(f
,&swf
)) fprintf(stderr
,"WriteSWF() failed.\n");
210 swf_FreeTags(&swf
); // cleanup