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
20 * Zou Lunkai, zoulunkai@gmail.com
22 * Test "Jumping backward with dynamic instances in static depth zone removed"
24 * run as ./displaylist_depths_test9
28 * Frame | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
29 * --------+---+---+---+---+---+---+---+
30 * Event | |PPp| p | p | * | p | J |
32 * P = place (by PlaceObject2)
33 * p = place (by ActionScript)
39 * frame2: place a static DisplayObject at depth -16381 at position (10,200);
40 * place a static DisplayObject at depth -16380 at position (100,200);
41 * replace the DisplayObject at depth -16380 with a dynamic DisplayObject;
42 * frame3: create a script DisplayObject at depth -10;
43 * frame4: create a script DisplayObject at depth -20;
44 * frame6: create a script DisplayObject at depth -30;
45 * frame7: jump back to frame 5 and stop
49 * Before the jump we have 5 instances.
50 * After the jump only two timeline instances keep alive, all dynamic instances get removed;
51 * Seven instances have been constructed in total.
54 #include "ming_utils.h"
60 #define OUTPUT_VERSION 6
61 #define OUTPUT_FILENAME "displaylist_depths_test9.swf"
63 SWFDisplayItem
add_static_mc(SWFMovie mo
, const char* name
, int depth
, int x
, int y
, int width
, int height
);
66 add_static_mc(SWFMovie mo
, const char* name
, int depth
, int x
, int y
, int width
, int height
)
72 sh
= make_fill_square (-(width
/2), -(height
/2), width
, height
, 255, 0, 0, 255, 0, 0);
73 mc
= newSWFMovieClip();
74 SWFMovieClip_add(mc
, (SWFBlock
)sh
);
76 SWFMovieClip_nextFrame(mc
);
78 it
= SWFMovie_add(mo
, (SWFBlock
)mc
);
79 SWFDisplayItem_setDepth(it
, depth
);
80 SWFDisplayItem_moveTo(it
, x
, y
);
81 SWFDisplayItem_setName(it
, name
);
88 main(int argc
, char** argv
)
91 SWFMovieClip dejagnuclip
;
92 SWFDisplayItem it1
, it2
;
95 const char *srcdir
=".";
100 //fprintf(stderr, "Usage: %s <mediadir>\n", argv[0]);
105 mo
= newSWFMovieWithVersion(OUTPUT_VERSION
);
106 SWFMovie_setDimension(mo
, 800, 600);
107 SWFMovie_setRate (mo
, 2);
109 dejagnuclip
= get_dejagnu_clip((SWFBlock
)get_default_font(srcdir
), 10, 0, 0, 800, 600);
110 SWFMovie_add(mo
, (SWFBlock
)dejagnuclip
);
111 SWFMovie_nextFrame(mo
);
114 // Add a "static3" at depth 3 with origin at 10,200.
115 // Add a "static4" at depth 4 with origin at 100,200.
116 // Replace "static4" with a dynamic movieClip "dup0".
117 it1
= add_static_mc(mo
, "static3", 3, 10, 200, 20, 20);
118 check_equals(mo
, "static3.getDepth()", "-16381");
119 it2
= add_static_mc(mo
, "static4", 4, 100, 200, 20, 20);
120 SWFDisplayItem_addAction(it2
, newSWFAction(
121 "_root.note(this+' constructed');"
122 "_root.mc4Constructed++;"
123 ), SWFACTION_CONSTRUCT
);
124 check_equals(mo
, "static4.getDepth()", "-16380");
125 add_actions(mo
, "duplicateMovieClip('/static4', 'dup0', -16380);");
126 check_equals(mo
, "dup0.getDepth()", "-16380");
127 SWFMovie_nextFrame(mo
);
129 // Frame 3: create a script instance at depth -10.
130 check_equals(mo
, "dup0.getDepth()", "-16380");
131 add_actions(mo
, "duplicateMovieClip('static3', 'dup1', -10);");
132 check_equals(mo
, "dup1.getDepth()", "-10");
133 SWFMovie_nextFrame(mo
);
135 // Frame 4: create a script instance at depth -20.
137 "duplicateMovieClip('/:static3', 'dup2', -20);"
138 "check_equals(dup2.getDepth(), -20);");
139 SWFMovie_nextFrame(mo
);
141 // Frame 5: nothing new
142 SWFMovie_nextFrame(mo
);
144 // Frame 6: create a script instance at depth -30.
146 "duplicateMovieClip('_root.static3', 'dup3', -30);"
147 "check_equals(dup3.getDepth(), -30);");
148 SWFMovie_nextFrame(mo
);
150 // Frame 7: go to frame 5 and checks
151 check_equals(mo
, "typeof(static4)", "'undefined'");
152 check_equals(mo
, "typeof(dup0)", "'movieclip'");
153 check_equals(mo
, "_root.mc4Constructed", "2"); // static4 and dup0...
154 add_actions(mo
, "gotoAndStop(5);");
155 check_equals(mo
, "typeof(static3)", "'movieclip'");
156 check_equals(mo
, "typeof(static4)", "'movieclip'");
157 check_equals(mo
, "typeof(dup0)", "'undefined'");
158 check_equals(mo
, "mc4Constructed", "3"); // static4 twice, dup0 once
159 check_equals(mo
, "typeof(dup1)", "'undefined'");
160 check_equals(mo
, "typeof(dup2)", "'undefined'");
161 check_equals(mo
, "typeof(dup3)", "'undefined'");
162 add_actions(mo
, "totals();");
163 SWFMovie_nextFrame(mo
);
166 puts("Saving " OUTPUT_FILENAME
);
167 SWFMovie_save(mo
, OUTPUT_FILENAME
);