__proto__
ActionScript 3.0 does not support "hacking" the prototype chain. The use of
longer supported. For example:
ActionScript 2.0:
Class A {}
var a: A = new A;
trace(a.b)
a.__proto__.b = 10
trace(a.b)
class C {
var x:Number = 20;
}
var c:C = new C();
a.__proto__ = C.prototype;
trace(a.x);
ActionScript 3.0:
class A {}
var a: A = new A
trace(a.b)
a.__proto__.b = 10
a.constructor.prototype.b = 10; // Ok
trace(a.b)
class C {
var x:Number = 20;
}
var c:C = new C();
a.__proto__ = C.prototype;
Primitive types
Primitive types are sealed classes and do not have object wrappers. Primitive types in
ActionScript 3.0 are final, sealed classes. Furthermore, there are no object wrappers for
primitives. As a result, you cannot create properties on them at run time; for example:
ActionScript 2.0:
newstring = new String("hello");
newstring.sayHi = function() {
trace("hi!");
}
newstring.sayHi();
newstring2 = "hello";
// Output: undefined
// Ok
// Output: 10
// Output: 20
// Output: undefined
// Error, __proto__ unsupported.
// Use .constructor.prototype instead.
// Output: 10
// Error, __proto__ unsupported.
// .constructor.prototype is equivalent,
// though read only.
is no
__proto__
Miscellaneous
39
Need help?
Do you have a question about the FLEX 2-MIGRATING APPLICATIONS TO FLEX 2 and is the answer not in the manual?
Questions and answers