MACROMEDIA FLEX 2-MIGRATING APPLICATIONS TO FLEX 2 Manuale Utente Pagina 33

  • Scaricare
  • Aggiungi ai miei manuali
  • Stampa
  • Pagina
    / 184
  • Indice
  • SEGNALIBRI
  • Valutato. / 5. Basato su recensioni clienti
Vedere la pagina 32
Typing 33
Type detection
To perform type detection, you should use is rather than typeof or instanceof. The is
function examines types, whereas the
instanceof function looks at the prototype chain. The
instanceof function has been deprecated.
For example:
class B {
public function B() {}
}
class A extends B {
public function A() {
super();
}
}
class Main extends MovieClip {
public function Main() {
var a:A = new A();
trace(a instanceof B); // false; instanceof is deprecated.
trace(a instanceof A); // false; instanceof is deprecated.
trace(a is B); // true
trace(a is A); // true
}
}
Primitive types
In ActionScript 3.0, there is no longer a distinction between primitive types such as strings
and instances of the String class. All strings are instances of String; every datatype is an
instance of some class. The same is true for numbers and Booleans. For example:
print("test" == String("test")); // true
print("test" === String("test")); // true
print(45 == new Number(45)); // true
print(45 === new Number(45)); // true
print("one;two;three".substring(4,7)); // "two"
print((255).toString(16)); // "ff"
Non-assignment expressions
A non-assignment expression is any expression where a value is not assigned to a property (or
a variable or argument); for example:
var myVar : hintString ? String : Number;
Vedere la pagina 32
1 2 ... 28 29 30 31 32 33 34 35 36 37 38 ... 183 184

Commenti su questo manuale

Nessun commento