1 /***********************************************************************
3 * Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 ***********************************************************************
23 * Test case for the MovieClipLoader actionscript class
25 ***********************************************************************/
28 * run as ./movieclip_loader <mediadir>
30 * srcdir is where red.jpg, green.jp and blue.jpg are located
38 #define OUTPUT_VERSION 7
39 #define OUTPUT_FILENAME "moviecliploader_test.swf"
41 void add_clip(SWFMovie mo
, char* file
, char* name
, char* url
, int x
, int y
);
44 add_clip(SWFMovie mo
, char* file
, char* name
,
45 char* url
, int x
, int y
)
55 printf("Adding %s\n", file
);
57 fd
= fopen(file
, "r");
62 bm
= newSWFJpegBitmap(fd
);
63 sh
= newSWFShapeFromBitmap((SWFBitmap
)bm
, SWFFILL_CLIPPED_BITMAP
);
64 mc
= newSWFMovieClip();
65 SWFMovieClip_add(mc
, (SWFBlock
)sh
);
66 SWFMovieClip_nextFrame(mc
); /* showFrame */
67 it
= SWFMovie_add(mo
, (SWFBlock
)mc
);
68 SWFDisplayItem_setName(it
, name
);
69 SWFDisplayItem_moveTo(it
, x
, y
);
73 %s.onPress = function () { \
74 _root.CoverArtLoader.loadClip('%s', coverart); \
78 ac
= compileSWFActionCode(action
);
80 SWFMovie_add(mo
, (SWFBlock
)ac
);
84 main(int argc
, char** argv
)
93 const char *srcdir
=".";
95 SWFMovieClip mc_coverart
;
100 /*********************************************
104 *********************************************/
106 if ( argc
>1 ) srcdir
=argv
[1];
109 fprintf(stderr
, "Usage: %s <mediadir>\n", argv
[0]);
113 sprintf(file_red
, "%s/red.jpg", srcdir
);
114 sprintf(file_green
, "%s/green.jpg", srcdir
);
115 sprintf(file_blue
, "%s/blue.jpg", srcdir
);
118 * Test urls with and w/out 'file://' prefix.
119 * Test both jpeg and swf loading.
121 sprintf(url_red
, "file://%s/red.swf", srcdir
);
122 sprintf(url_green
, "file://%s/green.jpg", srcdir
);
123 sprintf(url_blue
, "%s/blue.swf", srcdir
);
126 puts("Setting things up");
129 Ming_useSWFVersion (OUTPUT_VERSION
);
130 Ming_setScale(1.0); /* so we talk twips */
133 SWFMovie_setDimension (mo
, 11000, 8000);
134 SWFMovie_setRate (mo
, 12.0);
135 SWFMovie_setBackground (mo
, 255, 255, 255);
137 /*****************************************************
139 * MovieClipLoader class
141 *****************************************************/
143 puts("Compiling MovieClipLoader actionscript");
145 /* Action for first frame */
146 ac
= compileSWFActionCode
149 CoverArtLoader = new MovieClipLoader(); \
151 SWFMovie_add(mo
, (SWFBlock
)ac
);
153 /* Add the LYNCH clip */
154 add_clip(mo
, file_red
, "red", url_red
, 200, 4419);
156 /* Add the GREEN clip */
157 add_clip(mo
, file_green
, "green", url_green
, 3800, 4419);
159 /* Add the BLUE clip */
160 add_clip(mo
, file_blue
, "blue", url_blue
, 7400, 4419);
162 /*****************************************************
164 * Add the coverart clip
166 *****************************************************/
168 puts("Adding coverart");
170 sh_coverart
= newSWFShape();
171 fstyle
= SWFShape_addSolidFillStyle(sh_coverart
, 0,0,0,255);
172 SWFShape_setRightFillStyle(sh_coverart
, fstyle
);
173 SWFShape_movePenTo(sh_coverart
, 3400, 3400);
174 SWFShape_drawLine(sh_coverart
, -3400, 0);
175 SWFShape_drawLine(sh_coverart
, 0, -3400);
176 SWFShape_drawLine(sh_coverart
, 3400, 0);
177 SWFShape_drawLine(sh_coverart
, 0, 3400);
179 mc_coverart
= newSWFMovieClip();
180 SWFMovieClip_add(mc_coverart
, (SWFBlock
)sh_coverart
);
181 SWFMovieClip_nextFrame(mc_coverart
); /* showFrame */
182 it
= SWFMovie_add(mo
, (SWFBlock
)mc_coverart
);
183 SWFDisplayItem_setName(it
, "coverart");
184 SWFDisplayItem_moveTo(it
, 3800, 500);
186 /*****************************************************
190 *****************************************************/
192 puts("Saving " OUTPUT_FILENAME
);
194 SWFMovie_nextFrame(mo
); /* showFrame */
196 SWFMovie_save(mo
, OUTPUT_FILENAME
);