initial revision.
[swftools.git] / swfs / PreLoaderTemplate.c
1 /* simple_viewer.c
2
3    Creates the swf file PreLoaderTemplate.swf. 
4    
5    Part of the swftools package.
6
7    Copyright (c) 2001 Matthias Kramm <kramm@quiss.org>
8  
9    This file is distributed under the GPL, see file COPYING for details 
10 */
11
12 #include <stdio.h>
13 #include <fcntl.h>
14 #include <math.h>
15 #include "rfxswf.h"
16
17 TAG* tag;
18
19 int main (int argc,char ** argv)
20 { SWF swf;
21   RGBA rgb;
22   SRECT r;
23   LPSHAPE s;
24   MATRIX m;
25   ActionTAG*a1,*a2,*a3;
26   S32 width = 826, height = 1169;
27   
28   int f,i,ls1,fs1;
29   int count;
30   int t;
31
32   memset(&swf,0x00,sizeof(SWF));        // set global movie parameters
33
34   swf.fileVersion    = 4;               // make flash 4 compatible swf
35   swf.frameRate      = 0x1900;          // about 0x19 frames per second
36   
37   swf.movieSize.xmax = 20*width;        // flash units: 1 pixel = 20 units
38   swf.movieSize.ymax = 20*height;
39
40   swf.firstTag = swf_InsertTag(NULL,ST_SETBACKGROUNDCOLOR);
41   tag = swf.firstTag;
42   rgb.r = 0xff;
43   rgb.g = 0xff;
44   rgb.b = 0xff;
45   swf_SetRGB(tag,&rgb);
46
47   tag = swf_InsertTag(tag,ST_DEFINESPRITE);
48   swf_SetU16(tag, 1); //id
49   swf_SetU16(tag, 0); //frames
50   tag = swf_InsertTag(tag,ST_END);
51   tag = swf_InsertTag(tag,ST_PLACEOBJECT2);
52   swf_ObjectPlace(tag, 1, 1, 0, 0, "loader");
53   
54   tag = swf_InsertTag(tag,ST_SHOWFRAME);
55
56     a1 = action_PushFloat(0, 12.0);
57     a1 = action_PushString(a1, "");
58     a1 = action_GetProperty(a1);
59     a1 = action_PushFloat(a1, 2.0);
60     a1 = action_Less(a1);
61     a1 = action_If(a1, 2);
62     a1 = action_GotoFrame(a1, 1);
63     a1 = action_End(a1);
64
65     a2 = action_Stop(0);
66     a2 = action_End(a2);
67
68   tag = swf_InsertTag(tag,ST_DOACTION);
69   swf_ActionSet(tag, a1);
70   
71   tag = swf_InsertTag(tag,ST_SHOWFRAME);
72   
73   tag = swf_InsertTag(tag,ST_DOACTION);
74   swf_ActionSet(tag, a2);
75   
76   tag = swf_InsertTag(tag,ST_REMOVEOBJECT2);
77   swf_SetU16(tag, 1);
78
79   tag = swf_InsertTag(tag,ST_DEFINESPRITE);
80   swf_SetU16(tag, 2); //id
81   swf_SetU16(tag, 0); //frames
82   tag = swf_InsertTag(tag,ST_END);
83   tag = swf_InsertTag(tag,ST_PLACEOBJECT2);
84   swf_ObjectPlace(tag, 2, 2, 0, 0, "movie");
85   
86   tag = swf_InsertTag(tag,ST_SHOWFRAME);
87   
88   tag = swf_InsertTag(tag,ST_END);
89
90   f = open("PreLoaderTemplate.swf",O_WRONLY|O_CREAT|O_TRUNC, 0644);
91   if FAILED(swf_WriteSWF(f,&swf)) fprintf(stderr,"WriteSWF() failed.\n");
92   close(f);
93
94   swf_FreeTags(&swf);                       // cleanup
95   return 0;
96 }
97
98