...
Add the following line to the strand setter function:
Code Block |
---|
//actionscript
IEventDispatcher(value).addEventListener(“viewChanged”,viewChangeChandler);
|
Implement the “viewChanged” Handler
There is no JavaScript equivalent for this step. Most of your work to set up the bead will be in the strand setter function.
Implement the Bead
For ActionScript, create Create the function to handle the “viewChanged” event:
Code Block |
---|
// actionscript
private function viewChangedHandler(event:Event):void
{
var textView:TextInputView = _strand.getBeadByType(TextInputView) as TextInputView;
if (textView) {
var textField:CSSTextField = textView.textField;
textField.displayAsPassword = true;
}
}
|
...
With the TextInputView, the next thing to do is get its underlying textField and set it to display as a password. CSSTextField is a FlexJS class that extends the ActionScript TextField to make it easier to apply styles to it using CSS. You can also have used the TextField type directly.
For Javascript, add the following line to the set_strand
function:
Code Block |
---|
value.element.type = 'password';
|
so the set_strand
function now reads:
Code Block |
---|
PasswordBead.prototype.set_strand = function(value)
{
this.strand_ = value;
value.element.type = 'password';
}
|
This is an example of making a functionally equivalent bead in JavaScript. Since the JavaScript component is just wrapping the HTML input element, which is a property of the strand, the bead can take the direct route of setting the element's type to "password"
.
Use the Bead
Updating the Manifest and Library
...