1 // level99.as - Data file for the levels.as test
3 // Copyright (C) 2005, 2006, 2007, 2009, 2010 Free Software
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 3 of the License, or
9 // (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 // Original author: David Rorex - drorex@gmail.com
28 static function main
(mc
)
30 mc
.createEmptyMovieClip
("ch", 1);
33 lineStyle
(1, 0x00000);
34 beginFill
(0x00FF00, 80);
41 lineTo
(x
+width
, y
+height
);
47 check_equals
(mc
._currentframe
, 1);
49 check
(_level0
.frameno
>= 2);
52 check_equals
(mc
.getDepth
(), -16285);
54 // _root is relative. TODO: check _lockroot effect !
55 check_equals
(mc
._root
, _level99
);
56 check_equals
(_root
, _level99
);
57 // "/" in path is relative !
58 check_equals
(eval
("/ch"), _level99
.ch
);
60 // The ""+ is there to force conversion to a string
61 check_equals
(""+mc
, "_level99");
63 // Mc level is _level0 ? why ?
64 check_equals
(mc
._level
, _level0
);
66 // check that we can acess back to _level0
67 check_equals
(_level0
.testvar
, 1239);
68 check_equals
(_level0
.testvar2
, true);
70 // check that we can acess back to _level5
71 check_equals
(_level5
.testvar
, 6789);
73 // check that we can modify vars on our own level
74 check_equals
(_level99
.testvar
, undefined);
75 _level99
.testvar
= "hello";
76 check_equals
(_level99
.testvar
, "hello");
78 // check that we can modify vars on _level5
79 check_equals
(_level5
.testvar2
, undefined);
80 _level5
.testvar2
= "goodbye";
81 check_equals
(_level5
.testvar2
, "goodbye");
83 check_equals
(typeof(_level5
), 'movieclip');
84 var level5ref
= _level5
;
85 check_equals
(_level5
.getDepth
(), -16379);
86 _level5
.swapDepths
(10);
87 check_equals
(typeof(_level5
), 'undefined');
88 check_equals
(typeof(level5ref
), 'movieclip');
89 check_equals
(level5ref
.getDepth
(), '10');
90 check_equals
(level5ref
._target
, '_level16394');
91 check_equals
(typeof(_level16394
), 'movieclip');
92 level5ref
.swapDepths
(20); // swapDepth doesn't work now because level5ref is out of the static depth zone
93 check_equals
(level5ref
.getDepth
(), '10');
94 check_equals
(level5ref
._target
, '_level16394');
95 check_equals
(level5ref
._name
, '');
96 xcheck_equals
(""+level5ref
, '_level5');
98 var level99ref
= _level99
;
99 _level99
.swapDepths
(30);
100 check_equals
(level99ref
.getDepth
(), '30');
101 check_equals
(level99ref
._target
, '_level16414');
102 level99ref
.swapDepths
(40); // swapDepth doesn't work now because level99ref is out of the static depth zone
103 check_equals
(level99ref
.getDepth
(), '30');
104 check_equals
(level99ref
._target
, '_level16414');
105 check_equals
(level99ref
._name
, '');
106 xcheck_equals
(""+level99ref
, '_level99');
108 note
("Setting up onEnterFrame for "+mc
.ch
);
110 mc
.ch
.l5ref
= level5ref
;
111 mc
.ch
.l99ref
= level99ref
;
112 mc
.ch
.onEnterFrame
= function()
114 //note(this+".enterFrame -- l5ref is "+this.l5ref+" -- l99ref is "+this.l99ref);
115 if ( this.count
> 4 )
117 check_equals
(this.l5ref
._target
, '_level16394');
118 check_equals
(this.l99ref
._target
, '_level16414');
120 _level16394
.onUnload
= function() {
121 check
(false); // should not be executed
123 _level16394
.removeMovieClip
();
125 check_equals
(typeof(this.l5ref
), 'movieclip');
126 check_equals
(typeof(this.l5ref
)._target
, 'undefined');
127 check_equals
(typeof(this.l5ref
.getDepth
), 'undefined');
128 check_equals
(typeof(_level16364
), 'undefined')
131 // TODO: add tests for:
132 // - sane swapping between to levels,
133 // - swapping & removing _level0
137 delete this.onEnterFrame
;
142 this.l5ref
.swapDepths
(this.l99ref
);