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

  • Scaricare
  • Aggiungi ai miei manuali
  • Stampa
  • Pagina
    / 184
  • Indice
  • SEGNALIBRI
  • Valutato. / 5. Basato su recensioni clienti
Vedere la pagina 174
Using mixins 175
Using mixins
You can no longer attach a function to a class, unless that class has prior knowledge of that
function. For example, you can no longer do this:
UIComponent.prototype.doSomething = myFunction
or this:
dataGridInstance.doSomething = myFunction
You can still declare a Function type property on an Object and then supply an
implementation of that function later. For example:
class MyButton extends Button {
var doSomething:Function;
public function processInput(condition:Boolean):void {
if (condition)
doSomething();
}
}
and then:
var b:MyButton = new MyButton();
b.doSomething = function () { ... };
b.processInput(true);
You can also apply mixins to dynamic classes without their prior knowledge, as the following
example shows:
dynamic class MyButton extends Button {
...
}
and then:
// You can mix in any function onto an instance of a dynamic class:
var b:MyButton = new MyButton();
b.anyFunctionNameYouCanImagine = function () { ... };
// After it's added, you can call the function as follows:
b.anyFunctionNameYouCanImagine();
The only class in the Flex class library that is dynamic is the Object class. In most cases, you
must create your own class.
Vedere la pagina 174
1 2 ... 170 171 172 173 174 175 176 177 178 179 180 ... 183 184

Commenti su questo manuale

Nessun commento