Home > Adobe Flex > Flex 4: Changing the “displayAsPassword” default character

Flex 4: Changing the “displayAsPassword” default character

Today I ran into a situation where I wanted to display my password characters as a bullet versus the default asterisk (“*”).

I thought this would be pretty simple to do but realized after digging through the Flex 4 SDK that there was no public property I could set to change this. I tried hacking commitProperties and a couple of other methods but came up short in those areas as well until I found the exact spot in the Flex libraries where this character was defined:

RichEditableText.as (line 679)

1
2
3
4
    /**
     *  @private
     */
    mx_internal var passwordChar:String = "*";

A-ha! I see here that it’s prefixed with the “mx_internal” namespace and I remembered from other examples around the web that you can easily tap into that namespace and modify properties not normally meant to be modified.

Luckily, I had already extended the TextInput class for various other reasons and decided to add an event listener for the CREATION_COMPLETE lifecycle event of the component. This was added in the constructor:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import mx.core.mx_internal;
 
/**
 * Constructor
 */
public function myTextInput()
{
	super();
 
	this.addEventListener( FlexEvent.CREATION_COMPLETE, onCreationComplete );
}
 
private function onCreationComplete( event : FlexEvent ) : void
{
	//change internal passwordChar to a bullet versus an asterisk
	this.textDisplay.mx_internal::passwordChar = "●";
}

…and voila! By tapping into the mx_internal namespace, I found I could modify the normally private variable “passwordChar” and set it to something I preferred better (in this case, the bullet point used in some sites like Twitter).

Hope this helps someone!

Categories: Adobe Flex Tags:
  1. February 4th, 2019 at 04:45 | #1

    For most up-to-date news you have to pay a visit the web and on world-wide-web I found this website as a finest web site
    for hottest updates.

  2. February 23rd, 2019 at 19:52 | #2

    You are so cool! I don’t thinnk I’ve read someyhing like this before.
    So grfeat to discover another person with unique thoughts on tis topic.
    Seriously.. thank you for starting this up. This site is one thinng that’s needed on the web, someone
    with a bit of originality!

  3. February 24th, 2019 at 16:06 | #3

    My family all the time say that I am killing my time here at net, but I know I
    am getting knowledge all the time by reading thes pleasant
    articles or reviews.

  4. March 12th, 2019 at 19:41 | #4

    Thanks to my father who informed me on the topic of this
    weblog, this blog is actually awesome.

  5. March 14th, 2019 at 08:08 | #5

    Fastidious replies in return of this query with solid arguments and describing all
    concerning that.

  6. March 18th, 2019 at 11:48 | #6

    Hmm is anyone else encountering problems with the images
    on this blog loading? I’m trying to figure
    out if its a problem on my end or if it’s the blog. Any responses would be greatly appreciated.

Comment pages
1 13 14 15 435
  1. March 19th, 2014 at 11:13 | #1
  2. April 30th, 2014 at 01:00 | #2
  3. December 31st, 2018 at 08:24 | #3
  4. February 2nd, 2019 at 20:25 | #4