Macromedia flex 2-migrating applications to flex 2 Manual De Usuario

Descargar
Página de 184
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.