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!
certainly like your web site but you need to take a look
at the spelling on quite a few of your posts. Several of them are rife with spelling problems and
I in finding it very troublesome to tell the truth nevertheless I will definitely come again again.
Looking To Obtain Massage Hold? What You Need To Know 유흥
How To Discover A The Ultimate Birthday Party Places BUDAL
10 Practical Tips On Getting Enough Sleep HiOP
Hmm is anyone else having problems with the pictures on this blog loading?
I’m trying to figure out if its a problem on my end or if it’s
the blog. Any feedback would be greatly appreciated.
Pretty! This has been a really wonderful article. Many thanks for providing these details.
Cheap Hotels – Have A Nice Pleasant Stay HiOP
Wedding Reception Music – Top 10 Tips 아이러브밤
For newest information you have to pay a visit world-wide-web and on the web I found this site as a most excellent site for latest updates.
Great! Thank you so much for sharing this. I can’t wait to use it. Visit free stresser
Body Care And Body Oils Information 울산유흥