MACROMEDIA FLEX 2-MIGRATING APPLICATIONS TO FLEX 2 Instrukcja Użytkownika Strona 39

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 184
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 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";
Przeglądanie stron 38
1 2 ... 34 35 36 37 38 39 40 41 42 43 44 ... 183 184

Komentarze do niniejszej Instrukcji

Brak uwag