MACROMEDIA FLEX 2-MIGRATING APPLICATIONS TO FLEX 2 Manual do Utilizador Página 39

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 184
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes
Vista de página 38
Miscellaneous 39
__proto__
ActionScript 3.0 does not support “hacking” the prototype chain. The use of __proto__ is no
longer supported. For example:
ActionScript 2.0:
Class A {}
var a: A = new A;
trace(a.b) // Output: undefined
a.__proto__.b = 10 // Ok
trace(a.b) // Output: 10
class C {
var x:Number = 20;
}
var c:C = new C();
a.__proto__ = C.prototype;
trace(a.x); // Output: 20
ActionScript 3.0:
class A {}
var a: A = new A
trace(a.b) // Output: undefined
a.__proto__.b = 10 // Error, __proto__ unsupported.
// Use .constructor.prototype instead.
a.constructor.prototype.b = 10; // Ok
trace(a.b) // Output: 10
class C {
var x:Number = 20;
}
var c:C = new C();
a.__proto__ = C.prototype; // Error, __proto__ unsupported.
// .constructor.prototype is equivalent,
// though read only.
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";
Vista de página 38
1 2 ... 34 35 36 37 38 39 40 41 42 43 44 ... 183 184

Comentários a estes Manuais

Sem comentários