"Fossies" - the Fresh Open Source Software Archive 
Member "gnash-0.8.10/testsuite/misc-swfc.all/action_execution_order_test10.sc" (19 Jan 2012, 6553 Bytes) of package /linux/www/old/gnash-0.8.10.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Paradox source code syntax highlighting (style:
standard) with prefixed line numbers.
Alternatively you can here
view or
download the uninterpreted source code file.
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 */
18
19 /*
20 * Zou Lunkai, zoulunkai@gmail.com
21 *
22 * Test actions execution order
23 *
24 * Description:
25 *
26 * frame3: DoAction: Create user defined onContruct, onLoad and onUnload for both mc1 and mc2.
27 * Place mc1 by PlaceObject2.
28 * DoAction.
29 * Place mc2 by PlaceObject2.
30 * DoAction.
31 *
32 * frame4: DoAction.
33 * delete mc1 by RemoveObject2.
34 * DoAction.
35 * delete mc2 by RemoveObject2.
36 * DoAction.
37 *
38 * frame8:
39 * PlaceObject(mc4), DoInitAction(mc4), DoInitAction(mc5), PlaceObject(mc5)
40 * - user defined onInitialize(mc4) isn't called
41 * - user defined onInitialize(mc5) isn't called
42 * - user defined onConstruct(mc4) is called
43 * - user defined onConstruct(mc5) is called
44 *
45 * Expected behaviour:
46 * (1) user defined onLoad should not be triggered in this case(when allEventFlags == zero).
47 * (guess: might be a pp bug)
48 * (2) If DoAction is before RemoveObject2, then actions in DoAction should be executed before
49 * onUnload, otherwise after onUnload.
50 * (3) Frame actions(frameNum>0): first placed last executed.
51 *
52 */
53
54
55 .flash bbox=800x600 filename="action_execution_order_test10.swf" background=white version=7 fps=12
56
57 .frame 1
58 .action:
59 #include "Dejagnu.sc"
60
61 _root.as_order1 = '0+';
62 _root.as_order2 = '0+';
63 check_equals(_root._currentframe, 1);
64 .end
65
66 // Define 3 shapes(b1, b2, b3)
67 .box b1 fill=green width=100 height=100
68 .box b2 fill=red width=100 height=100
69 .box b3 fill=yellow width=100 height=100
70 .box b4 fill=blue width=100 height=100
71
72 .frame 2
73
74 .sprite mc1 // Define a sprite mc1
75 .frame 1
76 .put b1
77 .action:
78 _root.as_order1 += '2+';
79 .end
80 .frame 3
81 .action:
82 _root.as_order2 += '3+';
83 .end
84 .frame 10
85 .end
86
87 .sprite mc2 // Define a sprite mc2
88 .frame 1
89 .put b2
90 .action:
91 _root.as_order1 += '4+';
92 .end
93 .frame 3
94 .action:
95 _root.as_order2 += '2+';
96 .end
97 .frame 10
98 .end
99
100 .sprite mc3 // Define a sprite mc3
101 .frame 2
102 .action:
103 _root.as_order2 += '1+';
104 .end
105 .frame 10
106 .end
107
108 .frame 3
109
110 .action:
111 // user defined onConstruct has no chance to be executed
112 mc1.onConstruct = function () {_root.as_order1 += 'xx+';};
113 mc2.onConstruct = function () {_root.as_order1 += 'xx+';};
114
115 // user defined onLoad won't be triggered if allEventFlags is zero(this case),
116 // otherwise, it will be triggered. A PP bug???
117 mc1.onLoad = function () {_root.as_order1 += 'YY+';};
118 mc2.onLoad = function () {_root.as_order1 += 'YY+';};
119
120 mc1.onUnload = function () {_root.as_order1 += '7+';};
121 mc2.onUnload = function () {_root.as_order1 += '9+';};
122
123 _root.as_order1 += "1+";
124 .end
125
126 .put mc1 x = 0 y = 300 // Place mc1
127
128 .action:
129 _root.as_order1 += "3+";
130 .end
131
132 .put mc2 x = 100 y = 300 // Place mc2
133
134 .action:
135 _root.as_order1 += "5+";
136 .end
137
138
139
140 .frame 4
141 .put mc3 // Place mc3
142
143
144 .frame 6
145
146 .action:
147 _root.as_order1 += "6+";
148 .end
149
150 .del mc1 // delete mc1 by RemoveObject2
151
152 .action:
153 _root.as_order1 += "8+";
154 .end
155
156 .del mc2 // delete mc2 by RemoveObject2
157
158 .action:
159 _root.as_order1 += "10+";
160 .end
161
162 .del mc3 // delete mc3 by RemoveObject2
163
164 .frame 7
165 .action:
166 check_equals(_root.as_order1, '0+1+2+3+4+5+6+7+8+9+10+');
167 check_equals(_root.as_order2, '0+1+2+3+');
168 .end
169
170
171 //
172 // seperate tests for user defined onInitialize, onConstruct, onLoad
173 //
174 .frame 8
175 .sprite mc4
176 .put b4 x=100 y=300
177 .end
178 .sprite mc5
179 .put b4 x=100 y=400
180 .end
181 .put mc4 // PlaceObject2(mc4)
182 .initaction mc4:
183 _root.mc4_onConstruct_executed = false;
184
185 _root.note("mc4 init actions");
186 _root.check_equals(typeof(mc4), 'movieclip');
187 // What a bad bug the pp has !
188 // First query of __proto__ turns it into the correct prototype
189 // (MovieClip.prototype) buf first query returns the *old* rather
190 // then the new value
191 // UPDATE: Company knew about this, he mentions that unless for SWF6
192 // the first time a movieclip's __proto__ is queried it always
193 // returns Object.prototype.
194 _root.xcheck(mc4.__proto__ == Object.prototype); // returns wrong answer at first, gnash does the right thing here
195 _root.check(mc4.__proto__ != Object.prototype); // and correct at second and subsequent queries
196 _root.check_equals(mc4.__proto__, MovieClip.prototype); // <--- this is the correct one
197
198 mc4.onInitialize = function () {
199 _root.note("mc4 user defined onInitialize");
200 _root.check(false); // should not be executed
201 };
202 mc4.onConstruct = function() {
203 _root.note("mc4 user defined onConstruct");
204 _root.mc4_onConstruct_executed = true;
205 };
206 mc4.onLoad = function() {
207 _root.note("mc4 user defined onLoad");
208 _root.check(false); // should not be executed
209 };
210 .end
211 .initaction mc5:
212 _root.mc5_onConstruct_executed = false;
213
214 mc5.onInitialize = function () {
215 _root.note("mc5 user defined onInitialize");
216 _root.check(false); // should not be executed
217 };
218 mc5.onConstruct = function() {
219 _root.note("mc5 user defined onConstruct");
220 _root.mc5_onConstruct_executed = true;
221 };
222 mc5.onLoad = function() {
223 _root.note("mc5 user defined onLoad");
224 _root.check(false); // should not be executed
225 };
226 .end
227 .put mc5 // PlaceObject2(mc5)
228
229 .frame 9
230 .action:
231 check_equals(mc4_onConstruct_executed, true);
232 check_equals(mc5_onConstruct_executed, true);
233 .end
234
235 .frame 15
236 .action:
237 totals(9);
238 stop();
239 .end
240
241
242 .end // end of the file
243
244