2 * Copyright (C) 2007, 2009, 2010, 2011 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
21 * observed behaviour(SWF6,7,8):
22 * if the given depth is occupied, PlaceObjec2(PLACE) tag won't replace the orginal one.
24 * observed behaviour(SWF5):
25 * too odd to understand :(
32 #include "ming_utils.h"
34 #define OUTPUT_VERSION 6
35 #define OUTPUT_FILENAME "place_object_test2.swf"
40 main(int argc
, char** argv
)
43 SWFMovieClip mc1
, mc2
, dejagnuclip
;
45 SWFDisplayItem it1
, it2
;
47 const char *srcdir
=".";
52 fprintf(stderr
, "Usage: %s <mediadir>\n", argv
[0]);
57 mo
= newSWFMovieWithVersion(OUTPUT_VERSION
);
58 SWFMovie_setDimension(mo
, 800, 600);
59 SWFMovie_setRate (mo
, 12.0);
61 dejagnuclip
= get_dejagnu_clip((SWFBlock
)get_default_font(srcdir
), 10, 0, 0, 800, 600);
62 SWFMovie_add(mo
, (SWFBlock
)dejagnuclip
);
63 add_actions(mo
, "testvar1 = 0; testvar2 = 0;");
64 SWFMovie_nextFrame(mo
); // frame1
69 mc1
= newSWFMovieClip();
70 sh1
= make_fill_square (100, 100, 60, 60, 255, 0, 0, 255, 0, 0);
71 SWFMovieClip_add(mc1
, (SWFBlock
)sh1
);
72 SWFMovieClip_nextFrame(mc1
);
74 mc2
= newSWFMovieClip();
75 sh2
= make_fill_square (300, 100, 60, 60, 255, 0, 0, 0, 255, 0);
76 SWFMovieClip_add(mc2
, (SWFBlock
)sh2
);
77 SWFMovieClip_nextFrame(mc2
);
79 SWFMovie_nextFrame(mo
); // frame2
82 // Place mc1 at depth 3, place mc1 at depth3 again with a different name;
83 // Observed behaviour: later place does not create a new DisplayObject
85 it1
= SWFMovie_add(mo
, (SWFBlock
)mc1
);
86 SWFDisplayItem_setDepth(it1
, 3);
87 SWFDisplayItem_setName(it1
, "static_mc1");
88 SWFDisplayItem_addAction(it1
,
89 newSWFAction(" _root.testvar1++; trace(this); trace(_root.testvar1); "),
90 SWFACTION_INIT
| SWFACTION_CONSTRUCT
| SWFACTION_ONLOAD
);
92 it2
= SWFMovie_add(mo
, (SWFBlock
)mc2
);
93 SWFDisplayItem_setDepth(it2
, 3);
94 SWFDisplayItem_setName(it2
, "static_mc2");
95 SWFDisplayItem_addAction(it2
,
96 newSWFAction(" _root.testvar2++; trace(this); trace(_root.testvar2); "),
97 SWFACTION_INIT
| SWFACTION_CONSTRUCT
| SWFACTION_ONLOAD
);
99 check_equals(mo
, "typeof(static_mc1)", "'movieclip'");
100 if(OUTPUT_VERSION
> 5)
102 // check that "static_mc2" doesn't get placed
103 check_equals(mo
, "typeof(static_mc2)", "'undefined'");
107 // check that "static_mc2" does get placed
108 check_equals(mo
, "typeof(static_mc2)", "'movieclip'");
110 SWFMovie_nextFrame(mo
); // frame3
112 if(OUTPUT_VERSION
> 5)
114 check_equals(mo
, "testvar1", "3");
115 check_equals(mo
, "testvar2", "0");
119 // swf5 does not support CONSTRUCT event
120 check_equals(mo
, "testvar1", "2");
121 check_equals(mo
, "testvar2", "2");
125 // Place mc2 at depth 3 again.
126 // Observed behaviour: no new DisplayObject gets created
128 it2
= SWFMovie_add(mo
, (SWFBlock
)mc2
);
129 SWFDisplayItem_setDepth(it2
, 3);
130 SWFDisplayItem_setName(it2
, "static_mc3");
132 check_equals(mo
, "typeof(static_mc1)", "'movieclip'");
133 if(OUTPUT_VERSION
> 5)
135 // check that "static_mc3" doesn't get placed
136 check_equals(mo
, "typeof(static_mc3)", "'undefined'");
140 // check that "static_mc3" does get placed
141 check_equals(mo
, "typeof(static_mc3)", "'movieclip'");
143 SWFMovie_nextFrame(mo
); // frame4
146 // Place mc1 at depth 3 again with ratio set to 0.2
147 // Observed behaviour: no new DisplayObject get placed(created).
149 it2
= SWFMovie_add(mo
, (SWFBlock
)mc1
);
150 SWFDisplayItem_setDepth(it2
, 3);
151 SWFDisplayItem_setName(it2
, "static_mc4");
152 SWFDisplayItem_setRatio(it2
, 0.2);
154 check_equals(mo
, "typeof(static_mc1)", "'movieclip'");
155 if(OUTPUT_VERSION
> 5)
157 // check that "static_mc4" doesn't get placed.
158 check_equals(mo
, "typeof(static_mc4)", "'undefined'");
162 // check that "static_mc4" does get placed.
163 check_equals(mo
, "typeof(static_mc4)", "'movieclip'");
165 SWFMovie_nextFrame(mo
); // frame5
168 // Place mc2 at depth 3 again with ratio set to 0.2
169 // Observed behaviour: no new DisplayObject get placed(created).
171 it2
= SWFMovie_add(mo
, (SWFBlock
)mc2
);
172 SWFDisplayItem_setDepth(it2
, 3);
173 SWFDisplayItem_setName(it2
, "static_mc5");
174 SWFDisplayItem_setRatio(it2
, 0.2);
176 check_equals(mo
, "typeof(static_mc1)", "'movieclip'");
177 if(OUTPUT_VERSION
> 5)
179 // check that "static_mc5" doesn't get placed.
180 check_equals(mo
, "typeof(static_mc5)", "'undefined'");
184 // check that "static_mc5" does get placed.
185 check_equals(mo
, "typeof(static_mc5)", "'movieclip'");
187 SWFMovie_nextFrame(mo
); // frame6
191 // Odd, where are the movieclips now?
192 // Note that all those movieclips are defined above but not now.
194 if(OUTPUT_VERSION
<= 5)
197 "check_equals(typeof(static_m1), 'undefined');"
198 "check_equals(typeof(static_m2), 'undefined');"
199 "check_equals(typeof(static_m3), 'undefined');"
200 "check_equals(typeof(static_m4), 'undefined');"
201 "check_equals(typeof(static_m5), 'undefined');"
204 add_actions(mo
, " _root.totals(); stop(); ");
205 SWFMovie_nextFrame(mo
); // frame7
208 puts("Saving " OUTPUT_FILENAME
);
209 SWFMovie_save(mo
, OUTPUT_FILENAME
);