Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
Developer
Posts: 133
Registered: ‎12-02-2010
My Device: Z10 & Dev Alpha C
Accepted Solution

Prevent LoginDialog From Closing When Entering wrong Password

[ Edited ]

How can I prevent the LoginDialog from Closing when the user enters a wrong password? I tried event.stopImmediatePropogation and event.stopPropogation()... When the user clicks the "Login" button the Login Dialog Box closes when I want it to stay open and have it display its errorText = "Incorrect Password"

 

private function login(password:String):void{
	var alert:LoginDialog = new LoginDialog();
	alert.title = "Login";
	alert.message = "Please enter your Password:";				
	alert.passwordPrompt = "password";
	alert.addButton( 'Quit' );
	alert.addButton( 'Login' );
	alert.addEventListener(Event.SELECT, alertButtonClicked);
	alert.show(); 
	
	function alertButtonClicked( event : Event ) : void
	{
		switch (event.target.getItemAt(event.target.selectedIndex).label){
			
			case "Login":
				if (alert.password == password){
					continueAfterLogin()
				}else{
					alert.errorText = "Incorrect Password!"
					// i tried both of these
					event.stopImmediatePropagation();
					event.stopPropagation();
				}
				break;
			case "Quit":
				stage.nativeWindow.close();
				break;
			
		}
		
	}
}

 

The only thing that seems to work is : callLater(alert.show);

 

 

	case "Login":
	if (alert.password == password){
		continueAfterLogin()
	}else{
		alert.errorText = "Incorrect Password!"
		callLater(alert.show);
	}
	break;

 

---------------------------------------------------------------------
Developer of Stocks for Blackberry 10
Developer
Posts: 217
Registered: ‎04-26-2012
My Device: Z10

Re: Prevent LoginDialog From Closing When Entering wrong Password

Easy:

 

alert.cancelRequired=true;

 

This will keep the dialog when a button is pressed and you will have to remove it when needed on button event handler with:

 

alert.cancel();
           

My apps for Playbook: PlayEpub Book Reader with epub and FB2 support, Google Reader, ReaditLater - Net Files Share Explorer Get access to your network shared files- FFSync Sync your Firefox bookmarks and passwords
Developer
Posts: 133
Registered: ‎12-02-2010
My Device: Z10 & Dev Alpha C

Re: Prevent LoginDialog From Closing When Entering wrong Password

I knew I was missing something so simple :smileyhappy: . Thanks for the quick reply and help!

---------------------------------------------------------------------
Developer of Stocks for Blackberry 10