Accept 13766 as a valid sound duration too (some liblame versions give that number...
[gnash.git] / testsuite / misc-swfc.all / movieclip_destruction_test4.sc
blobb754d9883729e09d96fcbe2c8e43f3b61d0eb2f7
1 /*
2  *   Copyright (C) 2005, 2006, 2007, 2009, 2010 Free Software Foundation, Inc.
3  * 
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.
8  * 
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
16  *
17  */ 
20  * Zou Lunkai, zoulunkai@gmail.com
21  * 
22  * Test destruction of brother movieClips.
23  *
24  * Description:
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
28  *   
29  * Expected behaviour:
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
36  * 
37  */
40 .flash  bbox=800x600 filename="movieclip_destruction_test4.swf" background=white version=7 fps=12
42 .frame 1
43   .action:
44    #include "Dejagnu.sc"
45    _root.as_order = '0+';
46   .end
47   
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 
53 .frame 2
55   .sprite mc11
56     .frame 1 
57       .action:
58         _root.note("Running frame1["+this._currentframe+"] actions of mc11["+this._target+"] (adding green square @ 400,200)");
59       .end
60     .put green_square x=400 y=200
61   .end
62   
63   .sprite mc1
64     .frame 1 
65       .action:
66         _root.note("Running frame1["+this._currentframe+"] actions of mc1["+this._target+"] (adding green square @ 300,200 and mc11)");
67       .end
68       .put green_square x=300 y=200
69       .put mc11
70     .frame 6
71   .end 
72    
73   .sprite mc2
74     .frame 1 
75       .action:
76         _root.note("Running frame1["+this._currentframe+"] actions of mc2["+this._target+"] (adding red square)");
77       .end
78       .put red_square x=300 y=300
79     .frame 2 
80       .action:
81         _root.note("Running frame2["+this._currentframe+"] actions of mc2["+this._target+"] (nothing new)");
82       .end
83     .frame 3
84       .action:
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']();
91       .end
92   .end 
93   
94   .sprite mc31
95     .put blue_square x=400 y=400
96   .end
97   
98   .sprite mc3
99     .frame 1 
100       .action:
101         _root.note("Running frame1["+this._currentframe+"] actions of mc3["+this._target+"] (adding blue square)");
102       .end
103       .put blue_square x=300 y=400
104       .put mc31
105     .frame 6
106   .end 
107   
108   
109 .frame 3
110   .action:
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);
118     
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');
125     };
126     
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);
134     };
135     
136     //
137     // Define both parent onUnload and child onUnload
138     //
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);
144     };
145     
146     brother6.mc31.onUnload = function () {
147       // child mc31 not shifted
148       _root.check_equals(this.getDepth(), -16382);
149     };
150   .end
152 .frame 4
153   .action:
154     _root.note("Running frame3 actions of _root (nothing new)");
155   .end
158 .frame 5
159   .action:
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');
167   .end
168   
169   
170 .frame 10
171   .action:  
172     check_equals(typeof(brother1), 'undefined');
173     check_equals(typeof(brother2), 'movieclip');
174     check_equals(typeof(brother3), 'undefined');
175     stop();
176     totals(19);
177   .end
179 .end