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"
22 int useDefineButton2 = 0; // set this to 1 to use DefineButton2 Tags
23 // instead of DefineButton1
25 int main (int argc,char ** argv)
30 ActionTAG*a1,*a2,*a3, *actiontoset;
31 S32 width=300,height = 300;
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);
51 for(count=1;count<4;count++)
53 t = swf_InsertTag(t,ST_DEFINESHAPE);
54 swf_ShapeNew(&s); // create new shape instance
55 rgb.r = rgb.b = rgb.g = 0x00;
56 ls1 = swf_ShapeAddLineStyle(s,40,&rgb);
57 rgb.r = count*0x40; rgb.b = 0xff;
58 fs1 = swf_ShapeAddSolidFillStyle(s,&rgb);
59 swf_SetU16(t,33+count); // now set character ID
64 swf_SetRect(t,&r); // set shape bounds
65 swf_SetShapeHeader(t,s); // write all styles to tag
66 swf_ShapeSetAll(t,s,0,0,ls1,fs1,0); // move to (0,0), select linestyle ls1 and no fillstyle
67 swf_ShapeSetCircle(t,s,width*10,height*10,width*10,height*10);
68 swf_ShapeSetEnd(t); // finish drawing
69 swf_ShapeFree(s); // clean shape structure (which isn't needed anymore after writing the tag)
72 a1 = action_SetTarget(0, "movie");
73 a1 = action_NextFrame(a1);
74 a1 = action_SetTarget(a1, "");
77 //a2 = action_GetUrl(a2, "test.swf","_level0"); // load a swf
78 //a2 = action_GetUrl(a2, "index.html","_this"); // load html in new window
79 a2 = action_GetUrl(0, "http://www.quiss.org/swftools/index.html","_parent"); // load html in this window
82 a3 = action_GotoFrame(0,33);
89 t = swf_InsertTag(t,ST_DEFINEBUTTON);
90 swf_SetU16(t,31); //id
91 swf_ButtonSetRecord(t,BS_UP|BS_HIT,34,1,NULL,NULL);
92 swf_ButtonSetRecord(t,BS_OVER,35,1,NULL,NULL);
93 swf_ButtonSetRecord(t,BS_DOWN,36,1,NULL,NULL);
94 swf_SetU8(t,0); // end of button records
96 swf_ActionSet(t,actiontoset);
100 t = swf_InsertTag(t,ST_DEFINEBUTTON2);
101 swf_SetU16(t,ID_BUTTON); //id
102 swf_ButtonSetFlags(t, 0); //menu=no
103 swf_ButtonSetRecord(t,BS_UP|BS_HIT,34,1,NULL,NULL);
104 swf_ButtonSetRecord(t,BS_OVER,35,1,NULL,NULL);
105 swf_ButtonSetRecord(t,BS_DOWN,36,1,NULL,NULL);
106 swf_SetU8(t,0); // end of button records
108 swf_ButtonSetCondition(t, BC_OVERDOWN_OVERUP);
109 swf_ActionSet(t,actiontoset);
111 swf_ButtonPostProcess(t, 1); // don't forget!
118 t = swf_InsertTag(t,ST_PLACEOBJECT2);
119 swf_ObjectPlace(t, ID_BUTTON, 2,0,0,0);
121 t = swf_InsertTag(t,ST_SHOWFRAME);
122 t = swf_InsertTag(t,ST_END);
124 f = open("buttontest.swf",O_WRONLY|O_CREAT, 0644);
125 if FAILED(swf_WriteSWF(f,&swf)) fprintf(stderr,"WriteSWF() failed.\n");
128 swf_FreeTags(&swf); // cleanup