john
john

Reputation:

Disable Yes button in FLEX

I would like to disable Yes button in an Alert box. Is this possible?

Thanks in advance.

Upvotes: 0

Views: 2760

Answers (5)

Matt MacLean
Matt MacLean

Reputation: 19656

Try this:

import mx.core.mx_internal;
use namespace mx_internal;

private var theAlert:Alert;

public function showAlert():void
{
  theAlert = Alert.show("Saving Changes...", "", Alert.YES + Alert.NO);
  theAlert.mx_internal::alertForm.mx_internal::buttons[0].enabled = false;
}

public function hideAlert():void
{
  PopUpManager.removePopUp(theAlert);
}

Upvotes: 1

webinky
webinky

Reputation:

I will suggest to you to create you own custom alert, see an example here

Upvotes: -1

cliff.meyers
cliff.meyers

Reputation: 17734

I would extend the Alert class with your own custom class. Add a bitmask that controls which buttons are enabled or disabled. Then override createChildren() and disable the buttons as they are created.

Upvotes: 0

leolobato
leolobato

Reputation: 2379

You mean disable or hide?

I don't think you can enable/disable buttons in a Alert box, but you choose which buttons will be shown, for example:

Alert.show('Text Copied!', 'Alert Box', Alert.YES | Alert.NO);

Valid buttons:

mx.controls.Alert.OK
mx.controls.Alert.YES
mx.controls.Alert.NO
mx.controls.Alert.CANCEL

Full documentation here: Alert control

If you really meant to enable/disable buttons, you could make your own MXML component based on TitleWindow.

Upvotes: 5

Alistair Knock
Alistair Knock

Reputation: 1836

See if the examples on this flex examples page help you.

Upvotes: 0

Related Questions