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 13th, 2018 at 15:41 | #1

    Thanks for finally talking about >Flex 4: Changing the “displayAsPassword”
    default character | eonflex.com <Liked it!

  2. February 14th, 2018 at 21:01 | #2

    You need to be a part of a contest for one of the most useful blogs on the net.

    I’m going to recommend this blog!

  3. February 16th, 2018 at 12:36 | #3

    Wohh just what I was looking for, appreciate it for putting up.

  4. February 17th, 2018 at 20:04 | #4

    At this time it looks like Expression Engine is the top blogging platform available right now.
    (from what I’ve read) Is that what you’re using on your blog?

  5. February 18th, 2018 at 01:13 | #5

    I’m pretty pleased to uncover this website.
    I want to to thank you for your time for this particularly fantastic read!!
    I definitely savored every bit of it and i also have you saved to
    fav to see new information in your blog.

  6. February 18th, 2018 at 10:21 | #6

    Your style is unique in comparison to other people I’ve read stuff from.

    Thanks for posting when you’ve got the opportunity, Guess I’ll just bookmark this site.

  7. February 18th, 2018 at 16:51 | #7

    My developer is trying to persuade me to move to .net
    from PHP. I have always disliked the idea because of the expenses.
    But he’s tryiong none the less. I’ve been using WordPress
    on various websites for about a year and am concerned about switching to another platform.
    I have heard very good things about blogengine.net. Is there
    a way I can transfer all my wordpress content into it? Any help would be greatly appreciated!

  8. February 18th, 2018 at 18:49 | #8

    A smartphone also is likewise more useful thnan the Oculus, consisting of for things besides
    home entertainment. Additionally, peeople who buyy them normally already have cellular phone
    bills, so that part does nnot enhance the overall expenditure.

Comment pages
1 11 12 13 435
  1. March 19th, 2014 at 11:13 | #1
  2. April 30th, 2014 at 01:00 | #2