3 Example implementation for creating a button with rfxswf
5 Part of the swftools package.
7 Copyright (c) 2000, 2001 Matthias Kramm <kramm@quiss.org>
8 Rainer Böhme <rfxswf@reflex-studio.de>
10 This file is distributed under the GPL, see file COPYING for details
16 #include "../rfxswf.h"
20 int useDefineButton2 = 0; // set this to 1 to use DefineButton2 Tags
21 // instead of DefineButton1
23 int main (int argc,char ** argv)
28 ActionTAG*a1,*a2,*a3, *actiontoset;
29 S32 width=300,height = 300;
34 memset(&swf,0x00,sizeof(SWF)); // set global movie parameters
36 swf.fileVersion = 4; // make flash 4 compatible swf
37 swf.frameRate = 0x1900; // about 0x19 frames per second
39 swf.movieSize.xmax = 20*width; // flash units: 1 pixel = 20 units
40 swf.movieSize.ymax = 20*height;
42 swf.firstTag = swf_InsertTag(NULL,ST_SETBACKGROUNDCOLOR);
49 for(count=0;count<4;count++)
51 t = swf_InsertTag(t,ST_DEFINESHAPE);
52 swf_ShapeNew(&s); // create new shape instance
53 rgb.r = rgb.b = rgb.g = 0x00;
54 ls1 = swf_ShapeAddLineStyle(s,40,&rgb);
55 rgb.r = count*0x40; rgb.b = 0xff;
56 fs1 = swf_ShapeAddSolidFillStyle(s,&rgb);
57 swf_SetU16(t,33+count); // now set character ID
62 swf_SetRect(t,&r); // set shape bounds
63 swf_SetShapeHeader(t,s); // write all styles to tag
64 swf_ShapeSetAll(t,s,0,0,ls1,fs1,0); // move to (0,0), select linestyle ls1 and no fillstyle
65 swf_ShapeSetCircle(t,s,width*10,height*10,width*10,height*10);
66 swf_ShapeSetEnd(t); // finish drawing
67 swf_ShapeFree(s); // clean shape structure (which isn't needed anymore after writing the tag)
70 a1 = swf_ActionStart(t);
71 action_SetTarget("movie");
77 a2 = swf_ActionStart(t);
78 //action_GetUrl("test.swf","_level0"); // load a swf
79 //action_GetUrl("index.html","_this"); // load html in new window
80 action_GetUrl("http://www.quiss.org/swftools/index.html","_parent"); // load html in this window
84 a3 = swf_ActionStart(t);
93 t = swf_InsertTag(t,ST_DEFINEBUTTON);
94 swf_SetU16(t,31); //id
95 swf_ButtonSetFlags(t, 0); //menu=no
96 swf_ButtonSetRecord(t,0x01,33,1,0,0);
97 swf_ButtonSetRecord(t,0x02,34,1,0,0);
98 swf_ButtonSetRecord(t,0x04,35,1,0,0);
99 swf_ButtonSetRecord(t,0x08,36,1,0,0);
101 swf_SetActions(t,actiontoset);
106 t = swf_InsertTag(t,ST_DEFINEBUTTON2);
107 swf_SetU16(t,31); //id
108 swf_ButtonSetFlags(t, 0); //menu=no
109 swf_ButtonSetRecord(t,0x01,33,1,0,0);
110 swf_ButtonSetRecord(t,0x02,34,1,0,0);
111 swf_ButtonSetRecord(t,0x04,35,1,0,0);
112 swf_ButtonSetRecord(t,0x08,36,1,0,0);
115 swf_ButtonSetCondition(t, 4);
116 swf_SetActions(t,actiontoset);
119 swf_ButtonSetCondition(t, 0);
124 swf_ButtonPostProcess(t, 2);
127 t = swf_InsertTag(t,ST_PLACEOBJECT2);
128 swf_ObjectPlace(t, 31, 2,0,0,0);
130 t = swf_InsertTag(t,ST_SHOWFRAME);
131 t = swf_InsertTag(t,ST_END);
133 f = open("button.swf",O_WRONLY|O_CREAT, 0644);
134 if FAILED(swf_WriteSWF(f,&swf)) fprintf(stderr,"WriteSWF() failed.\n");
137 swf_FreeTags(&swf); // cleanup