Flex Managers (mx.managers)
Flex Managers refer to components in the mx.managers package that manage
various aspects of a Flex application.
Potentially useful Managers:
- DragManager - Manages drag-and-drop operations, which let you move data from one place to another in a Flex application.
- FocusManager - An instance manages the focus on components in response to mouse activity or keyboard activity.
- PopUpManager - Creates new top-level windows and places or removes those windows from the layer on top of all other visible windows (layering), used for popup dialogs, menus, and dropdowns.
- More managers are described at http://livedocs.adobe.com/flex/3/langref/mx/managers/package-detail.html
Drag Manager (mx.managers.DragManager)
The DragManager class is used for managing drag-and-drop
operations for Flex applications.
All its methods and properties are static, so you do not need to create an instance of it.
The IDragManager interface and DragManager}} class are defined in the
{{{mx.managers package.
Key DragManager Methods
The doDrag() function begins a drag-and-drop operation for a drag source.
// ask the DragManger to begin a drag-and-drop operation DragManager.doDrag( dragInitiator, dragSource, mouseEvent, dragProxy );
The showFeedback() function indicates the type of drop operation
(copy, link, move, none) will occur for a drop target.
// indicate the type of drop that will occur (copy, link, move, none) DragManager.showFeedback( DragManager.LINK );
The acceptDragDrop() function indicates that a drop target accepts
a drag-and-drop operation.
// signal to the drop manager that this will accept the item DragManager.acceptDragDrop( dropTarget );
(Please refer to the full DragManager LiveDocs for more detailed information.)
Focus Manager (mx.managers.FocusManager)
A FocusManager instance manages the focus of components that comprise a "tab loop" in
response to mouse activity or keyboard activity (Tab key).
There can be several FocusManager instances in an application.
The IFocusManager interface and FocusManager}} class are defined in the
{{{mx.managers package.
All components that can be managed by the FocusManager implement the
mx.managers.IFocusManagerComponent interface.
Controls with Focus
There are several controls that implement the IFocusManagerComponent interface and
can therefore receive focus.
Examples of components that can receive focus: Button, TextInput, TextArea, etc.
To get the control with focus we'll call a FocusManager instance's
getFocus() method.
The getFocus() method returns an instance of IFocusManagerComponent (or null).
// within an application, for instance, there is a focusManager property var textArea:TextArea = focusManager.getFocus() as TextArea;
A FocusManager also managers the concept of a defaultButton, which is the Button on a form that dispatches a click event when the Enter key is pressed depending on where focus is at that time.
PopUp Manager (mx.managers.PopUpManager)
The PopUpManager creates new top-level windows used for popup dialogs, menus, and dropdowns.
The PopUpManager also handles layering of popups and provides modality, so that windows below the
popup cannot receive mouse events.
All its methods and properties are static, so you do not need to create an instance of it.
The IPopUpManager interface and PopUpManager}} class are defined in the
{{{mx.managers package.
Key PopUpManager Functions
The addPopUp() function is used to display a window or dialog that can then be
centered using the centerPopUp() function.
// create a dialog (using the TitleWindow class) var dialog:TitleWindow = new TitleWindow(); // display the dialog as a pop-up PopUpManager.addPopUp( dialog, this, true ); // center the dialog PopUpManager.centerPopUp( dialog );
The removePopUp() function can be used to effectively hide a window or dialog.
// hide the dialog PopUpManager.remoevPopUp( dialog );
(Please refer to the full PopUpManager LiveDocs for more detailed information.)
Related Links:
- http://livedocs.adobe.com/flex/3/langref/mx/managers/package-detail.html
- http://livedocs.adobe.com/flex/3/langref/mx/managers/DragManager.html
- http://livedocs.adobe.com/flex/3/langref/mx/managers/FocusManager.html
- http://livedocs.adobe.com/flex/3/langref/mx/managers/PopUpManager.html
- Drag-and-Drop in Flex
- Flex Dialogs

