2 * Copyright (C) 2005-2013 Free Software Foundation, Inc.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #include "ming_utils.h"
27 #define OUTPUT_VERSION 6
28 #define OUTPUT_FILENAME "empty_clip_action_test.swf"
30 // So this is about as hacky as you get. The idea is that we change the
31 // CHANGEOBJECT2 tag so that the first action (containing just a single
32 // null-byte) is truncated to nothing: event_length is updated to zero, the
33 // following two bytes are skipped and then of course the tag length itself has
34 // to be reduced by one.
36 // So far as I'm aware you can't do this programmatically in Ming, but of
37 // course if the output stream ever changes this will be completely broken.
38 void spesiulOutputMethod(byte b
, void *data
);
39 void spesiulOutputMethod(byte b
, void *data
)
41 static long count
= 0;
43 FILE *f
= (FILE *)data
;
45 if (count
== 0x293b) {
49 if (count
== 0x2953) {
53 if (count
== 0x2954 || count
== 0x2955) {
66 main(int argc
, char** argv
)
69 SWFMovieClip mc2
, dejagnuclip
;
73 const char *srcdir
=".";
78 fprintf(stderr
, "Usage: %s <mediadir>\n", argv
[0]);
83 mo
= newSWFMovieWithVersion(OUTPUT_VERSION
);
84 SWFMovie_setDimension(mo
, 800, 600);
85 SWFMovie_setRate (mo
, 12.0);
87 dejagnuclip
= get_dejagnu_clip((SWFBlock
)get_default_font(srcdir
), 10, 0, 0, 800, 600);
88 SWFMovie_add(mo
, (SWFBlock
)dejagnuclip
);
89 add_actions(mo
, "x2=0;");
90 SWFMovie_nextFrame(mo
); /* 1st frame */
93 mc2
= newSWFMovieClip();
95 it2
= SWFMovie_add(mo
, (SWFBlock
)mc2
);
96 SWFDisplayItem_setDepth(it2
, 20);
97 SWFDisplayItem_setName(it2
, "mc2");
98 SWFDisplayItem_addAction(it2
,
99 compileSWFActionCode(""),
101 SWFDisplayItem_addAction(it2
,
102 compileSWFActionCode(" _root.note('onClipEnterFrame triggered'); "
104 SWFACTION_ENTERFRAME
);
106 SWFMovie_nextFrame(mo
); /* 2nd frame */
108 check_equals(mo
, "_root.x2", "14");
109 SWFMovie_nextFrame(mo
); /* 3rd frame */
111 SWFDisplayItem_remove(it2
);
113 SWFMovie_nextFrame(mo
); /* 4th frame */
115 add_actions(mo
, " _root.totals(); stop(); ");
116 SWFMovie_nextFrame(mo
); /* 5th frame */
119 puts("Saving " OUTPUT_FILENAME
);
121 // ..but wait! Now entering crazy-land.
122 fh
= fopen(OUTPUT_FILENAME
, "w");
123 SWFMovie_output(mo
, spesiulOutputMethod
, fh
);