Avg. Rating 3.5

Problem

You want to have a password input in your application, but "displayAsPassword" isn't adequate. Users are able to reveal the password by exploiting the NativeDrag functionality of AIR.

Solution

Proposed workaround: Extend TextInput or, for non-Flex applications the TextField class. Add an event listener for the NativeDragEvent.NATIVE_DRAG_START event. In the event handler, clear the clipboard content. Simple!

Detailed explanation

public class PasswordInput extends TextInput {
  public function PasswordInput() {
   super();
   displayAsPassword = true;
   addEventListener(NativeDragEvent.NATIVE_DRAG_START, dragStart);
  }
  
  private function dragStart(e:NativeDragEvent):void {
   e.clipboard.clearData(ClipboardFormats.TEXT_FORMAT);
  }
 }


+
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License. Permissions beyond the scope of this license, pertaining to the examples of code included within this work are available at Adobe.

Report abuse

Related recipes