Packagefeathers.core
Classpublic class PopUpManager
InheritancePopUpManager Inheritance Object

Product Version : Feathers 1.0.0

Adds a display object as a pop-up above all content.



Public Properties
 PropertyDefined By
  overlayFactory : Function
[static] A function that returns a display object to use as an overlay for modal pop-ups.
PopUpManager
  popUpCount : int
[static] [read-only] The current number of pop-ups.
PopUpManager
  popUpManagerFactory : Function
[static] A function that creates a pop-up manager.
PopUpManager
  root : DisplayObjectContainer
[static] The container where pop-ups are added.
PopUpManager
Public Methods
 MethodDefined By
  
addPopUp(popUp:DisplayObject, isModal:Boolean = true, isCentered:Boolean = true, customOverlayFactory:Function = null):DisplayObject
[static] Adds a pop-up to the stage.
PopUpManager
  
centerPopUp(popUp:DisplayObject):void
[static] Centers a pop-up on the stage.
PopUpManager
  
defaultOverlayFactory():DisplayObject
[static] The default factory that creates overlays for modal pop-ups.
PopUpManager
  
[static] The default factory that creates a pop-up manager.
PopUpManager
  
forStarling(starling:Starling):IPopUpManager
[static] Returns the IPopUpManager associated with the specified Starling instance.
PopUpManager
  
isPopUp(popUp:DisplayObject):Boolean
[static] Determines if a display object is a pop-up.
PopUpManager
  
isTopLevelPopUp(popUp:DisplayObject):Boolean
[static] Determines if a display object is above the highest modal overlay.
PopUpManager
  
removeAllPopUps(dispose:Boolean = false):void
[static] Removes all pop-ups from the stage.
PopUpManager
  
removePopUp(popUp:DisplayObject, dispose:Boolean = false):DisplayObject
[static] Removes a pop-up from the stage.
PopUpManager
Property Detail
overlayFactoryproperty
overlayFactory:Function

A function that returns a display object to use as an overlay for modal pop-ups.

This function is expected to have the following signature:

function():DisplayObject

In the following example, the overlay factory is changed:

PopUpManager.overlayFactory = function():DisplayObject
{
    var overlay:Quad = new Quad( 100, 100, 0x000000 );
    overlay.alpha = 0.75;
    return overlay;
};


Implementation
    public static function get overlayFactory():Function
    public static function set overlayFactory(value:Function):void
popUpCountproperty 
popUpCount:int  [read-only]

The current number of pop-ups.

In the following example, we check the number of pop-ups:

if( PopUpManager.popUpCount > 0 )
{
    // do something
}


Implementation
    public static function get popUpCount():int
popUpManagerFactoryproperty 
public static var popUpManagerFactory:Function

A function that creates a pop-up manager.

This function is expected to have the following signature:

function():IPopUpManager

In the following example, the overlay factory is changed:

PopUpManager.popUpManagerFactory = function():IPopUpManager
{
    var popUpManager:DefaultPopUpManager = new DefaultPopUpManager();
    popUpManager.overlayFactory = function():DisplayObject
    {
        var overlay:Quad = new Quad( 100, 100, 0x000000 );
        overlay.alpha = 0.75;
        return overlay;
    };
    return popUpManager;
};

See also

rootproperty 
root:DisplayObjectContainer

The container where pop-ups are added. If not set manually, defaults to the Starling stage.

In the following example, the next tab focus is changed:

PopUpManager.root = someSprite;

The default value is null.


Implementation
    public static function get root():DisplayObjectContainer
    public static function set root(value:DisplayObjectContainer):void
Method Detail
addPopUp()method
public static function addPopUp(popUp:DisplayObject, isModal:Boolean = true, isCentered:Boolean = true, customOverlayFactory:Function = null):DisplayObject

Adds a pop-up to the stage.

The pop-up may be modal, meaning that an overlay will be displayed between the pop-up and everything under the pop-up manager, and the overlay will block touches. The default overlay used for modal pop-ups is created by PopUpManager.overlayFactory. A custom overlay factory may be passed to PopUpManager.addPopUp() to create an overlay that is different from the default one.

A pop-up may be centered globally on the Starling stage. If the stage or the pop-up resizes, the pop-up will be repositioned to remain in the center. To position a pop-up in the center once, specify a value of false when calling PopUpManager.addPopUp() and call PopUpManager.centerPopUp() manually.

Note: The pop-up manager can only detect if Feathers components have been resized in order to reposition them to remain centered. Regular Starling display objects do not dispatch a proper resize event that the pop-up manager can listen to.

Parameters

popUp:DisplayObject
 
isModal:Boolean (default = true)
 
isCentered:Boolean (default = true)
 
customOverlayFactory:Function (default = null)

Returns
DisplayObject
centerPopUp()method 
public static function centerPopUp(popUp:DisplayObject):void

Centers a pop-up on the stage. Unlike the isCentered argument passed to PopUpManager.addPopUp(), the pop-up will only be positioned once. If the stage or the pop-up resizes, PopUpManager.centerPopUp() will need to be called again if it should remain centered.

In the following example, we center a pop-up:

PopUpManager.centerPopUp( displayObject );

Parameters

popUp:DisplayObject

defaultOverlayFactory()method 
public static function defaultOverlayFactory():DisplayObject

The default factory that creates overlays for modal pop-ups. Creates an invisible Quad.

Returns
DisplayObject

See also

defaultPopUpManagerFactory()method 
public static function defaultPopUpManagerFactory():IPopUpManager

The default factory that creates a pop-up manager.

Returns
IPopUpManager

See also

forStarling()method 
public static function forStarling(starling:Starling):IPopUpManager

Returns the IPopUpManager associated with the specified Starling instance. If a pop-up manager hasn't been created yet, it will be created using PopUpManager.popUpManagerFactory.

In the following example, a pop-up is added:

PopUpManager.forStarling( Starling.current ).addPopUp( popUp );

Parameters

starling:Starling

Returns
IPopUpManager

See also

isPopUp()method 
public static function isPopUp(popUp:DisplayObject):Boolean

Determines if a display object is a pop-up.

In the following example, we check if a display object is a pop-up:

if( PopUpManager.isPopUp( displayObject ) )
{
    // do something
}

Parameters

popUp:DisplayObject

Returns
Boolean
isTopLevelPopUp()method 
public static function isTopLevelPopUp(popUp:DisplayObject):Boolean

Determines if a display object is above the highest modal overlay. If there are no modals overlays, determines if a display object is a pop-up.

Parameters

popUp:DisplayObject

Returns
Boolean
removeAllPopUps()method 
public static function removeAllPopUps(dispose:Boolean = false):void

Removes all pop-ups from the stage.

Parameters

dispose:Boolean (default = false)

removePopUp()method 
public static function removePopUp(popUp:DisplayObject, dispose:Boolean = false):DisplayObject

Removes a pop-up from the stage.

Parameters

popUp:DisplayObject
 
dispose:Boolean (default = false)

Returns
DisplayObject