Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Components in the FlexJS framework are bundles of functionality formed by composition, rather than by inheritance. The concept of adding functionality (composition) is different from most other UI approaches which tend to extend (inheritance) functionality resulting in more complex components or adding features (overloading) to existing componentcomponents.

For example, to have a text input field also include password and prompt features, you might use inheritance to create additional classes such as PasswordInput, PromptInput, and then PasswordAndPromptInput. You can see that this can quickly get out of control. Another option is to add these properties to the text input field and overload it with features. Feature overloading makes it convenient for developers but most of the time only a basic set of features are ever used. This means applications can be very large (byte-wise) because every component has code and properties it rarely needs.

...

The first example shows how to make the password bead. You will see how to compose the bead and how to add it to an existing component. Since FlexJS is available in ActionScript and JavaScript, the example shows how to make the bead using both languages simultaneously.

For this example, the password bead will modify the underlying text control (a TextField for ActionScript and the <input> element for JavaScript) so that it becomes a password entry field. These are the steps needed:

...

Create a new ActionScript class called PasswordInputBead and have it implement the IBead interface. Beads do not normally have their own user interface or display; they normally use the strand. Beads can create new UI components, but then they make the strand the parent of those components.

Panel

You can also create a new JavaScript class and call it PasswordInputBead as well - JavaScript versions must have the same class path as their ActionScript counterparts.

Implement the Strand Setter

Declare a private ivar called “_strand” and implement the setter function:

Code Block
// actionscript
public function set strand(value:IStrand):void
{
    _strand = value;
}
Code Block

// javascript
PasswordBead.prototype.set_strand = function(value)
{
    this.strand_ = value;
}

Set Up a Listener for the “viewChanged” Event

...