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!
Having read this I believed it was really informative.
I appreciate you finding the time and energy to put
this article together. I once again find myself spending a significant amount of time both reading and commenting.
But so what, it was still worthwhile!
I every time spent my half an hour to read this website’s posts every day along with a cup of
coffee.
Stress Relief For Women – 3 Super Guidelines For
Putting Yourself First 부산
Terrific post but I was wanting to know if you
could write a litte more on this topic? I’d be very thankful if you could elaborate a
little bit further. Thank you!
Spa Therapy OP (gaea.Ais.ne.jp)
Only Topic . Unique Bridal Shower Games OP
I could not refrain from commenting. Perfectly written!
I believe what you wrote made a great deal of sense. However, consider this, what if you
were to create a awesome title? I mean, I don’t want to
tell you how to run your blog, but suppose you added something that grabbed folk’s attention? I mean Flex 4: Changing
the “displayAsPassword” default character | eonflex.com is a little plain. You should look
at Yahoo’s home page and watch how they create post headlines to grab people interested.
You might try adding a video or a picture or two to grab
people excited about what you’ve written. Just my opinion, it could make your posts a little livelier.
Excellent blog here! Also your web site loads up
very fast! What web host are you using? Can I get your affiliate
link to your host? I wish my website loaded up as fast as yours lol
Kudos. Terrific stuff.
Amazing information, Kudos!
How The Following A Roulette System To Win At Roulette 에볼루션 주식시장 게임
Many thanks, Ample postings!
You need to take part in a contest for one of the best websites
on the web. I am going to highly recommend
this website!
You’re so interesting! I don’t think I’ve
read through anything like this before. So wonderful to discover somebody with a few unique thoughts on this issue.
Really.. thanks for starting this up. This website is one thing that’s needed on the internet, someone with a little originality!