Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: changed package for PasswordInputBead

...

Panel

This example already exists in the FlexJS library. You can look at the class files and follow along. (See; flex-js/frameworks/projects/HTML/as/src/org/apache/flex/html/accessories/PasswordInputBead.as)

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 for ActionScript:

...

Code Block
// actionscript
package org.apache.flex.html.staticControls.beadsaccessories
{
...
    public class PasswordInputBead implements IBead

...

Code Block
// javascript
goog.provide('org.apache.flex.html.staticControls.beadsaccessories.PasswordInputBead');
...
org.apache.flex.html.staticControls.beadsaccessories.PasswordInputBead = function()

Implement the Strand Setter

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

Code Block
// actionscript
public function set strand(value:IStrand):void
{
    _strand = value;
}
Code Block
// javascript
PasswordBeadPasswordInputBead.prototype.set_strand = function(value)
{
    this.strand_ = value;
}

...

so the set_strand function now reads:

Code Block
// javascript
PasswordBeadPasswordInputBead.prototype.set_strand = function(value)
{
    this.strand_ = value;
    value.element.type = 'password';
}

...

Code Block
import org.apache.flex.html.staticControls.beadsaccessories.PasswordInputBead; PasswordInputBead;

...

Code Block
<component id="PasswordInputBead" class="org.apache.flex.html.staticControls.beadsaccessories.PasswordInputBead" />

MXML

...