2 * Copyright (C) 2005, 2006, 2007, 2009, 2010,
3 * 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.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 * Test "Jumping backward to the middle of a DisplayObject's lifetime after removal and replacement(1)"
25 * Frame | 1 | 2 | 3 | 4 | 5 | 6 |
26 * --------+---+---+---+---+---+---+
27 * Event | |PP | * | RR| Pp| J |
29 * P = place (by PlaceObject2)
30 * p = place (by ActionScript)
31 * M = move to another depth (by swapDepth)
32 * R = remove ((by RemoveObject* tag)
39 * a static DisplayObjects is placed at depth 3 (-16381) [ a red square ]
40 * a static DisplayObject is placed at depth 4 (-16380) [ a black square ]
41 * frame3: nothing new.
43 * DisplayObject at depth 3 is removed;
44 * DisplayObject at depth 4 is removed;
46 * a static DisplayObject is placed at depth 3 (-16381) with ratio set to 2.0
47 * a dynamic DisplayObject is placed at depth 4 (-16380)
49 * frame6: jump to frame 3 and stop.
53 * After jump back, DisplayObjects placed at frame5 get destroyed, DisplayObjects placed at frame2
64 #include "ming_utils.h"
66 #define OUTPUT_VERSION 7
67 #define OUTPUT_FILENAME "loop_test4.swf"
71 main(int argc
, char** argv
)
74 SWFMovieClip mc1
, mc2
, dejagnuclip
;
75 SWFDisplayItem it1
, it2
;
78 const char *srcdir
=".";
83 //fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]);
88 Ming_useSWFVersion (OUTPUT_VERSION
);
91 SWFMovie_setDimension(mo
, 800, 600);
92 SWFMovie_setRate(mo
, 6);
94 // Frame 1: Place dejagnu clip
96 dejagnuclip
= get_dejagnu_clip((SWFBlock
)get_default_font(srcdir
), 10, 0, 0, 800, 600);
97 SWFMovie_add(mo
, (SWFBlock
)dejagnuclip
);
98 add_actions(mo
, "mc1Constructed=0; mc2Constructed=0; mc3Constructed=0;");
99 SWFMovie_nextFrame(mo
);
103 // Place red static movieClip1 DisplayObject at depth 3 (-16381)
104 // Place black static movieClip1 DisplayObject at depth 4 (-16380)
106 sh1
= make_fill_square (300, 300, 60, 60, 255, 0, 0, 255, 0, 0);
107 mc1
= newSWFMovieClip();
108 SWFMovieClip_add(mc1
, (SWFBlock
)sh1
);
109 SWFMovieClip_nextFrame(mc1
);
111 it1
= SWFMovie_add(mo
, (SWFBlock
)mc1
); //add movieClip1 to the _root
112 SWFDisplayItem_setDepth(it1
, 3);
113 SWFDisplayItem_setName(it1
, "movieClip1"); //name movieClip1
114 SWFDisplayItem_addAction(it1
, newSWFAction(
115 "_root.note(this+' constructed');"
116 "_root.mc1Constructed++;"
117 ), SWFACTION_CONSTRUCT
);
120 sh2
= make_fill_square (330, 270, 120, 120, 0, 0, 0, 0, 0, 0);
121 mc2
= newSWFMovieClip();
122 SWFMovieClip_add(mc2
, (SWFBlock
)sh2
);
123 SWFMovieClip_nextFrame(mc2
);
125 it2
= SWFMovie_add(mo
, (SWFBlock
)mc2
); //add movieClip2 to the _root
126 SWFDisplayItem_setDepth(it2
, 4);
127 SWFDisplayItem_setName(it2
, "movieClip2"); //name movieClip2
128 SWFDisplayItem_addAction(it2
, newSWFAction(
129 "_root.note(this+' constructed');"
130 "_root.mc2Constructed++;"),
131 SWFACTION_CONSTRUCT
);
133 SWFMovie_nextFrame(mo
);
135 // Frame3: nothing new
136 SWFMovie_nextFrame(mo
);
138 // Frame4: remove "movieClip1" and "movieClip2"
140 SWFDisplayItem_remove(it1
);
141 SWFDisplayItem_remove(it2
);
142 SWFMovie_nextFrame(mo
);
146 // Place red static movieClip3 DisplayObject at depth 3 (-16381)
147 // Place an empty dynamic movieClip4 DisplayObject at depth4 (-16380)
150 it1
= SWFMovie_add(mo
, (SWFBlock
)mc1
); //add movieClip3 to the _root
151 SWFDisplayItem_setDepth(it1
, 3);
152 SWFDisplayItem_setName(it1
, "movieClip3"); //name movieClip3
153 SWFDisplayItem_setRatio(it1
, 1.0); // It's important to set this, don't why yet.
154 SWFDisplayItem_addAction(it1
, newSWFAction(
155 "_root.note(this+' constructed');"
156 "_root.mc3Constructed++;"
157 ), SWFACTION_CONSTRUCT
);
159 add_actions(mo
, "_root.createEmptyMovieClip('movieClip4', -16380);");
161 SWFMovie_nextFrame(mo
);
164 // Frame4: check, gotoAndStop(3), check..
166 check_equals(mo
, "typeof(movieClip1)", "'undefined'");
167 check_equals(mo
, "typeof(movieClip2)", "'undefined'");
168 check_equals(mo
, "typeof(movieClip3)", "'movieclip'");
169 check_equals(mo
, "typeof(movieClip4)", "'movieclip'");
170 check_equals(mo
, "_root.mc1Constructed", "1");
171 check_equals(mo
, "_root.mc2Constructed", "1");
172 check_equals(mo
, "_root.mc3Constructed", "1");
174 SWFMovie_add(mo
, (SWFBlock
)newSWFAction( "gotoAndStop(3);"));
176 check_equals(mo
, "typeof(movieClip1)", "'movieclip'");
177 check_equals(mo
, "typeof(movieClip2)", "'movieclip'");
178 check_equals(mo
, "typeof(movieClip3)", "'undefined'");
179 check_equals(mo
, "typeof(movieClip4)", "'undefined'");
180 check_equals(mo
, "_root.mc1Constructed", "2");
181 check_equals(mo
, "_root.mc2Constructed", "2");
182 check_equals(mo
, "_root.mc3Constructed", "1");
184 SWFMovie_add(mo
, (SWFBlock
)newSWFAction( "totals(); stop();" ));
185 SWFMovie_nextFrame(mo
);
188 puts("Saving " OUTPUT_FILENAME
);
189 SWFMovie_save(mo
, OUTPUT_FILENAME
);