Packageardisia.managers.cursorManager
Classpublic class CursorManager
InheritanceCursorManager Inheritance Object

Displays mouse cursors natively at the OS level.

To use a custom cursor, the cursor must be first registered via the registerCursor() method. After registration, use the cursor via setCursor(). The exception to this rule is that all of the cursors in the DefaultCursors class are always available.

This class is completely static so there is no need to initialize it before use.

If a user opens a ContextMenu via a right click, this manager will revalidate the cursor to keep any possible custom cursors displayed. However, when a native (OS managed) context menu is opened, very strange unpredictable mouse events are dispatched and custom mouse behaviour isn't reliable. Thus, it is highly recommended that users either route all right clicks to an Ardisia FlexContextMenu or disable the OS context menu altogether by adding a global right_click mouse listener. See the online docs for more information.

View the technical documentation on the Ardisia Labs website for more information.



Public Properties
 PropertyDefined By
  availableCursors : Vector.<CursorData>
[static] The vector of CursorData objects that are available because they have been registered.
CursorManager
  colorMode : String = auto
[static] The default color mode to use for the default cursors that have both a black and white version.
CursorManager
  currentCursor : CursorData
[static] Returns the CursorData object for the currently displayed cursor.
CursorManager
  currentPriority : Number
[static] Returns the priority of the currently displayed cursor.
CursorManager
  cursorList : Vector.<CursorListData>
[static] The array of cursors to be displayed on the screen, as set by setCursor() calls.
CursorManager
Public Methods
 MethodDefined By
  
registerCursor(name:String, hotSpot:Point, assets:Array, frameRate:uint):void
[static] Register a cursor for use.
CursorManager
  
[static] Removes all set cursors from the cursorList.
CursorManager
  
removeCursor(name:String, priority:uint, removeAll:Boolean = false):void
[static] Remove the most recent cursor matching the provided name and priority.
CursorManager
  
removeGroup(group:String):void
[static] Remove all the cursors with the specified group token.
CursorManager
  
setCursor(name:String, priority:uint = 1, group:String = null, forceNonNative:Boolean = false, systemManager:ISystemManager = null):void
[static] Sets a cursor by name, priority, and (optionally) group token.
CursorManager
  
[static] Remove all registered cursors.
CursorManager
  
unRegisterCursor(name:String):void
[static] Remove a registered cursor.
CursorManager
  
[static] Calls to this method will use the cursorList to determine the cursor that should be displayed.
CursorManager
Protected Methods
 MethodDefined By
  
addContextHandlers(sm:ISystemManager):void
[static] Add listeners for the context menu.
CursorManager
  
animationHandler(event:TimerEvent):void
[static] Handles the timer event used to animate the fake cursor.
CursorManager
  
busyHandler(event:MouseEvent):void
[static] Handles mouse events when the busy cursor is active.
CursorManager
  
contextMenuHandler(event:Event):void
[static] Handles events on the context menu.
CursorManager
  
getColor():String
[static] Return the cursor color theme to use (black/white).
CursorManager
  
[static] Returns the CursorData object in the availableCursors array.
CursorManager
  
[static] Register the cursor with the player's native mouse cursor support.
CursorManager
  
mouseHandler(event:MouseEvent):void
[static] Handles mouse events for the fake cursor.
CursorManager
  
removeBusyHandlers(sysManager:ISystemManager):void
[static] Remove the mouse event listeners for the busy cursor.
CursorManager
  
[static] Remove listeners for the context menu.
CursorManager
  
[static] Remove the fake cursor and all associated listeners.
CursorManager
Styles
 Style Description Defined By
  
allScrollCursor
Type: Class CSS Inheritance: no
Embedded graphics class for the all scroll cursor.
CursorManager
  
allScrollCursorHotspot
Type: Array CSS Inheritance: no
The hot spot for the all scroll cursor.
CursorManager
  
arrowFlexCursor
Type: Class CSS Inheritance: no
Embedded graphics class for the arrow flex cursor.
CursorManager
  
arrowFlexCursorHotspot
Type: Array CSS Inheritance: no
The hot spot for the arrow flex cursor.
CursorManager
  
busyCursorAssets
Type: Class CSS Inheritance: no
Class that initializes an array of embedded bitmap data to use for the animated busy cursor.
CursorManager
  
busyCursorFramerate
Type: Number CSS Inheritance: no
The frame rate for the busy cursor.
CursorManager
  
busyCursorHotspot
Type: Array CSS Inheritance: no
The hot spot for the busy cursor.
CursorManager
  
colResizeCursor
Type: Class CSS Inheritance: no
Embedded graphics class for the column resize cursor.
CursorManager
  
colResizeCursorHotspot
Type: Array CSS Inheritance: no
The hot spot for the column resize cursor.
CursorManager
  
crosshairCursor
Type: Class CSS Inheritance: no
Embedded graphics class for the crosshair cursor
CursorManager
  
crosshairCursorHotspot
Type: Array CSS Inheritance: no
The hot spot for the crosshair cursor.
CursorManager
  
eWResizeCursor
Type: Class CSS Inheritance: no
Embedded graphics class for the e-w resize cursor.
CursorManager
  
eWResizeCursorHotspot
Type: Array CSS Inheritance: no
The hot spot for the e-w resize cursor.
CursorManager
  
helpCursor
Type: Class CSS Inheritance: no
Embedded graphics class for the help cursor.
CursorManager
  
helpCursorHotspot
Type: Array CSS Inheritance: no
The hot spot for the help cursor.
CursorManager
  
moveCursor
Type: Class CSS Inheritance: no
Embedded graphics class for the move cursor.
CursorManager
  
moveCursorHotspot
Type: Array CSS Inheritance: no
The hot spot for the move cursor.
CursorManager
  
neSwResizeCursor
Type: Class CSS Inheritance: no
Embedded graphics class for the ne-sw resize cursor.
CursorManager
  
neSwResizeCursorHotspot
Type: Array CSS Inheritance: no
The hot spot for the ne-sw resize cursor.
CursorManager
  
notAllowedCursor
Type: Class CSS Inheritance: no
Embedded graphics class for the not allowed cursor.
CursorManager
  
notAllowedCursorHotspot
Type: Array CSS Inheritance: no
The hot spot for the not allowed cursor.
CursorManager
  
nSResizeCursor
Type: Class CSS Inheritance: no
Embedded graphics class for the n-s resize cursor.
CursorManager
  
nSResizeCursorHotspot
Type: Array CSS Inheritance: no
The hot spot for the n-s resize cursor.
CursorManager
  
nwSeResizeCursor
Type: Class CSS Inheritance: no
Embedded graphics class for the nw-sw resize cursor.
CursorManager
  
nwSeResizeCursorHotspot
Type: Array CSS Inheritance: no
The hot spot for the nw-sw resize cursor.
CursorManager
  
rotateCursor
Type: Class CSS Inheritance: no
Embedded graphics class for the rotate cursor.
CursorManager
  
rotateCursorHotspot
Type: Array CSS Inheritance: no
The hot spot for the rotate cursor.
CursorManager
  
rowResizeCursor
Type: Class CSS Inheritance: no
Embedded graphics class for the row resize cursor.
CursorManager
  
rowResizeCursorHotspot
Type: Array CSS Inheritance: no
The hot spot for the row resize cursor.
CursorManager
  
verticalTextCursor
Type: Class CSS Inheritance: no
Embedded graphics class for the vertical text cursor.
CursorManager
  
verticalTextCursorHotspot
Type: Array CSS Inheritance: no
The hot spot for the vertical text cursor.
CursorManager
Property Detail
availableCursorsproperty
public static var availableCursors:Vector.<CursorData>

The vector of CursorData objects that are available because they have been registered.

Cursors listed in the DefaultCursors class are only added here once they are displayed via setCursor(), but they always available. DefaultCursors cursors are only added here when they are set to save memory.

The default value is Vector.().

colorModeproperty 
public static var colorMode:String = auto

The default color mode to use for the default cursors that have both a black and white version.

If the mode is "auto", the color will be set to white if the OS flash is running inside of is detected as Windows and black is the OS is OS X.

Only applies to default cursors not yet registered. To re-register a default cursor with a new color, unregister the cursor first.

The default value is "auto".

currentCursorproperty 
public static var currentCursor:CursorData

Returns the CursorData object for the currently displayed cursor.

The default value is null.

currentPriorityproperty 
public static var currentPriority:Number

Returns the priority of the currently displayed cursor.

The default value is NaN.

cursorListproperty 
public static var cursorList:Vector.<CursorListData>

The array of cursors to be displayed on the screen, as set by setCursor() calls. Each element in the array is a CursorListData object.

Sorted by priority. Iterate over the vector to check each cursor.

Can also include flash.ui.MouseCursors or any cursor from the DefaultCursors class.

The default value is Vector..

Method Detail
addContextHandlers()method
protected static function addContextHandlers(sm:ISystemManager):void

Add listeners for the context menu.

Parameters

sm:ISystemManager — the SystemManager

animationHandler()method 
protected static function animationHandler(event:TimerEvent):void

Handles the timer event used to animate the fake cursor.

Parameters

event:TimerEvent — the TimerEvent that triggered the handler

busyHandler()method 
protected static function busyHandler(event:MouseEvent):void

Handles mouse events when the busy cursor is active.

Parameters

event:MouseEvent — the MouseEvent that triggered the handler

contextMenuHandler()method 
protected static function contextMenuHandler(event:Event):void

Handles events on the context menu.

Parameters

event:Event — the Event that triggered the handler

getColor()method 
protected static function getColor():String

Return the cursor color theme to use (black/white). If colorMode is "auto", the color will be automatically determined based on the OS.

Returns
String — String "white"
getCursorData()method 
protected static function getCursorData(name:String):CursorData

Returns the CursorData object in the availableCursors array.

Parameters

name:String — the name of the CursorData object to search for

Returns
CursorData — CursorData object
initializeCursor()method 
protected static function initializeCursor(cursor:CursorData):void

Register the cursor with the player's native mouse cursor support. Generally, should not be called outside of this class.

Parameters

cursor:CursorData

mouseHandler()method 
protected static function mouseHandler(event:MouseEvent):void

Handles mouse events for the fake cursor.

Parameters

event:MouseEvent — the MouseEvent that triggered the handler

registerCursor()method 
public static function registerCursor(name:String, hotSpot:Point, assets:Array, frameRate:uint):void

Register a cursor for use. Cursor names are unique. If a cursor has a name that is already registered, the new cursor will not be registered.

No need to register OS cursors in the flash.ui.MouseCursors class. They are always available. This is true for any cursor found in the DefaultCursors class.

Parameters

name:String — the name of the cursor used in setCursor()
 
hotSpot:Point — the Point relative to the upper-left origin that defines the cursor's hot region
 
assets:Array — an array of the embedded assets used to define the cursor. A typical cursor uses a single asset. However, animated cursors use multiple classes.
 
frameRate:uint — a uint of the framerate to animate the assets. Only relevant if the assets parameter's length is greater than one.

removeAllCursors()method 
public static function removeAllCursors():void

Removes all set cursors from the cursorList. Does not affect the registered cursors.

removeBusyHandlers()method 
protected static function removeBusyHandlers(sysManager:ISystemManager):void

Remove the mouse event listeners for the busy cursor.

Parameters

sysManager:ISystemManager — systemManager to remove the listeners from

removeContextHandlers()method 
protected static function removeContextHandlers():void

Remove listeners for the context menu.

removeCursor()method 
public static function removeCursor(name:String, priority:uint, removeAll:Boolean = false):void

Remove the most recent cursor matching the provided name and priority. If multiple cursors with the passed name and priority are set, repeated calls to this method would be necessary to remove them all, unless the third parameter "removeAll" is set to "true".

See the removeGroup() method for an alternative method of removing cursors.

Parameters

name:String — the name of the cursor to remove
 
priority:uint — the uint priority of the cursor to remove
 
removeAll:Boolean (default = false) — remove all cursors matching the name and priority

removeFakeCursor()method 
protected static function removeFakeCursor():void

Remove the fake cursor and all associated listeners. No need to remove from systemManager.

removeGroup()method 
public static function removeGroup(group:String):void

Remove all the cursors with the specified group token. Does not affect the registered cursors. Applies to all cursors within the group regardless of priority.

Parameters

group:String — the token String

setCursor()method 
public static function setCursor(name:String, priority:uint = 1, group:String = null, forceNonNative:Boolean = false, systemManager:ISystemManager = null):void

Sets a cursor by name, priority, and (optionally) group token.

Note, setting cursor via this method will not necessarily change the cursor. The cursor displayed is determined by set cursors' priorities with ties going to most recently set cursor.

Parameters

name:String — the name of the cursor to set
 
priority:uint (default = 1) — the uint priority
 
group:String (default = null) — an optional string that can serve to group certain cursors together so they can all be removed as a group
 
forceNonNative:Boolean (default = false) — true to display the cursor non-natively even if native cursors are supported
 
systemManager:ISystemManager (default = null) — the SystemManager to attach a contextMenu handler for a native cursor and the stage to add a fakeCursor if the cursor is fake

unregisterAllCursors()method 
public static function unregisterAllCursors():void

Remove all registered cursors.

unRegisterCursor()method 
public static function unRegisterCursor(name:String):void

Remove a registered cursor. Note, this method makes the un-registered cursor unavailable to be set until re-registered. To simply stop a cursor from being displayed without unregistering it, see removeCursor().

Parameters

name:String — the name of the Cursor to un-register

validateCursor()method 
public static function validateCursor():void

Calls to this method will use the cursorList to determine the cursor that should be displayed.

Call this function to reset the cursor if the cursor was lost for any reason or other components have changed the cursor.