views:

126

answers:

2

I want to create a dialog or alert box, where a DisplayObject would take and force the focus, until an okay button or something releases the lock. thanks.

+4  A: 

The easy way to do this is to make your "dialog" as big as the stage, with a whacking great transparent area around the dialog itself.

The transparent area can listen for any mouse clicks, and just swallow them (which will prevent them being picked up by stuff further back in the display list).

To show the alert, just stick it on top of everything else, When the user closes it, take it away again.

Anon.
+1  A: 

Hi Timmy,

To do this, you will need to disable access to all objects under your 'alert' DisplayObject. There are multiple ways of doing this, here 2 I can think off:

  1. Loop through the display list and disable any display objects under your alert depth wise.
  2. Cheat it with a blocker. When you display your alert, display another clip (could have alpha set to 0 ) that blocks the user from hovering/clicking objects. The blocker might need a bit of setup( buttonMode = true, useHandCursor = false, etc. )

This 'modal' behavior has been around for some so there might be no need to reinvent the wheel, depending of your current setup.

If you're using the Flex framework, you've got the functionality in, for Flash you can use the Alert Manager from the Yahoo! Flash Astra Components:

alert manager thumb

Goodluck,

George Profenza
thanks, at least I know i'm not missing something obvious (like a property or function somewhere!)
Timmy