1+ // Compile with:
2+ // mtasc -main -header 200:150:30 Test.as -swf test.swf -version 8
3+ class Test {
4+
5+ static function main (current) {
6+ var object = {};
7+ var values = {};
8+
9+ values [ "string" ] = "A String!" ;
10+ values [ "undefined" ] = undefined ;
11+ values [ "object" ] = {};
12+ values [ "function" ] = function () {
13+ trace ("// function called!" );
14+ if (this === object) {
15+ trace ("// this == object" );
16+ } else if (this === values ) {
17+ trace ("// this === values" );
18+ } else {
19+ trace ("// this == " + this );
20+ }
21+ };
22+
23+ object. __resolve = function (name ) {
24+ trace ("// __resolve(" + name + ") called!" );
25+ return values [ name ];
26+ };
27+
28+ trace ("object.string: " + object. string);
29+ trace ("object.undefined: " + object. undefined );
30+ trace ("object.object: " + object. object);
31+ trace ("object.function: " + object[ "function" ] );
32+ trace ("object.function(): " + object[ "function" ] ());
33+
34+ trace ("object.hasOwnProperty(\" function\" ): " + object. hasOwnProperty ("function" ));
35+
36+ trace ("" );
37+
38+ var Proto = function () {};
39+ Proto. prototype . __resolve = function (name ) {
40+ trace ("// Proto.prototype.__resolve function called!" );
41+ return values [ name ];
42+ };
43+ object = new Proto();
44+ object. string = "An overriden string!" ;
45+ Proto. prototype . onThePrototype = "This was on the prototype!" ;
46+ trace ("object.string: " + object. string);
47+ trace ("object.onThePrototype: " + object. onThePrototype);
48+ trace ("object.undefined: " + object. undefined );
49+ trace ("object.object: " + object. object);
50+ trace ("object.function: " + object[ "function" ] );
51+ trace ("object.function(): " + object[ "function" ] ());
52+
53+ trace ("object.hasOwnProperty(\" function\" ): " + object. hasOwnProperty ("function" ));
54+
55+ trace ("" );
56+
57+ object = {};
58+ object. addProperty("__resolve" , function () {return function () {return "resolved!" ; }}, null );
59+ trace ("object.foo with an addProperty __resolve: " + object. foo);
60+ }
61+ }
0 commit comments