2 * Copyright (C) 2005, 2006, 2007, 2009, 2010 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 destruction of brother movieClips.
25 * frame2: Export three movieclips: mc1-->mc11, mc2, mc3-->mc31
26 * frame3: attach 6 brother movieclips: brother{1,2,3,4,5,6}
27 * frame5: brother{1,3,4,5,6} are removed by brother2
30 * (1)clipA.removeMovieClip() won't shift its parent or child.
31 * (2)unload a parent automatically unload its children.
32 * (3)whether a child should be unreachable(destroyed) after unload
33 * is not dependent its parent's onUnload.
34 * (4)whether a parent should be unreachable(destroyed) after unload
35 * is dependent on its children' onUnload
40 .flash bbox=800x600 filename="movieclip_destruction_test4.swf" background=white version=7 fps=12
45 _root.as_order = '0+';
48 // Define 3 shapes(b1, b2, b3)
49 .box green_square fill=green width=100 height=100
50 .box red_square fill=red width=100 height=100
51 .box blue_square fill=blue width=100 height=100
58 _root.note("Running frame1["+this._currentframe+"] actions of mc11["+this._target+"] (adding green square @ 400,200)");
60 .put green_square x=400 y=200
66 _root.note("Running frame1["+this._currentframe+"] actions of mc1["+this._target+"] (adding green square @ 300,200 and mc11)");
68 .put green_square x=300 y=200
76 _root.note("Running frame1["+this._currentframe+"] actions of mc2["+this._target+"] (adding red square)");
78 .put red_square x=300 y=300
81 _root.note("Running frame2["+this._currentframe+"] actions of mc2["+this._target+"] (nothing new)");
85 _root.note("Running frame3["+this._currentframe+"] actions of mc2["+this._target+"] (removing brothers 1,3,4,5,6)");
86 _root.brother1['removeMovieClip']();
87 _root.brother3['removeMovieClip']();
88 _root.brother4['removeMovieClip']();
89 _root.brother5['removeMovieClip']();
90 _root.brother6['removeMovieClip']();
95 .put blue_square x=400 y=400
101 _root.note("Running frame1["+this._currentframe+"] actions of mc3["+this._target+"] (adding blue square)");
103 .put blue_square x=300 y=400
111 _root.note("Running frame3 actions of _root (attach brothers)");
112 _root.attachMovie("mc1", "brother1", 10);
113 _root.attachMovie("mc2", "brother2", 20);
114 _root.attachMovie("mc3", "brother3", 30);
115 _root.attachMovie("mc3", "brother4", 40);
116 _root.attachMovie("mc3", "brother5", 50);
117 _root.attachMovie("mc3", "brother6", 60);
119 // Define a parent onUnload
120 brother4.onUnload = function () {
121 _root.check_equals(this.getDepth(), -32809);
122 // child mc31 has no onUnload defined. child mc31 has been destroyed.
123 // Gnash fails by keeping the child alive(referenceable)
124 _root.check_equals(typeof(this.mc31), 'undefined');
127 // Define child onUnload
128 brother5.mc31.onUnload = function () {
129 // child mc31 has onUnload defined, not shifted.
130 _root.check_equals(this.getDepth(), -16382);
131 _root.check_equals(typeof(this), 'movieclip');
132 _root.check_equals(typeof(this._parent), 'movieclip');
133 _root.check_equals(this._parent.getDepth(), -32819);
137 // Define both parent onUnload and child onUnload
139 brother6.onUnload = function () {
140 _root.check_equals(this.getDepth(), -32829);
141 // child mc31 has onUnload defined, not shifted.
142 _root.check_equals(typeof(this.mc31), 'movieclip');
143 _root.check_equals(this.mc31.getDepth(), -16382);
146 brother6.mc31.onUnload = function () {
147 // child mc31 not shifted
148 _root.check_equals(this.getDepth(), -16382);
154 _root.note("Running frame3 actions of _root (nothing new)");
160 _root.note("Running frame5 actions of _root");
161 check_equals(typeof(brother1), 'undefined');
162 check_equals(typeof(brother2), 'movieclip');
163 check_equals(typeof(brother3), 'undefined');
164 check_equals(typeof(brother4), 'movieclip');
165 check_equals(typeof(brother5), 'movieclip');
166 check_equals(typeof(brother6), 'movieclip');
172 check_equals(typeof(brother1), 'undefined');
173 check_equals(typeof(brother2), 'movieclip');
174 check_equals(typeof(brother3), 'undefined');