Packageorg.flixel.system.input
Classpublic class Mouse
InheritanceMouse Inheritance FlxPoint Inheritance Object

This class helps contain and track the mouse pointer in your game. Automatically accounts for parallax scrolling, etc.



Public Properties
 PropertyDefined By
  screenX : int
Current X position of the mouse pointer on the screen.
Mouse
  screenY : int
Current Y position of the mouse pointer on the screen.
Mouse
  visible : Boolean
[read-only]
Mouse
  wheel : int
Current "delta" value of mouse wheel.
Mouse
 Inheritedx : Number
FlxPoint
 Inheritedy : Number
FlxPoint
Protected Properties
 PropertyDefined By
  _current : int
Helper variable for tracking whether the mouse was just pressed or just released.
Mouse
  _cursor : Bitmap
This is just a reference to the current cursor image, if there is one.
Mouse
  _cursorContainer : Sprite
A display container for the mouse cursor.
Mouse
  ImgDefaultCursor : Class
Mouse
  _last : int
Helper variable for tracking whether the mouse was just pressed or just released.
Mouse
  _lastWheel : int
Mouse
  _lastX : int
Helper variables for recording purposes.
Mouse
  _lastY : int
Mouse
  _out : Boolean
Helper for mouse visibility.
Mouse
  _point : FlxPoint
Mouse
  _screenPosition : FlxPoint
Mouse
Public Methods
 MethodDefined By
  
Mouse(CursorContainer:Sprite)
Constructor.
Mouse
 Inherited
FlxPoint
 Inherited
copyFromFlash(FlashPoint:Point):FlxPoint
FlxPoint
 Inherited
FlxPoint
 Inherited
copyToFlash(FlashPoint:Point):Point
FlxPoint
  
destroy():void
Mouse
  
getScreenPosition(Camera:FlxCamera = null, Point:FlxPoint = null):FlxPoint
Mouse
  
getWorldPosition(Camera:FlxCamera = null, Point:FlxPoint = null):FlxPoint
Mouse
  
handleMouseDown(event:MouseEvent):void
Event handler so FlxGame can update the mouse.
Mouse
  
handleMouseOut(event:MouseEvent):void
Event handler so FlxGame can update the mouse.
Mouse
  
handleMouseOver(event:MouseEvent):void
Event handler so FlxGame can update the mouse.
Mouse
  
handleMouseUp(event:MouseEvent):void
Event handler so FlxGame can update the mouse.
Mouse
  
handleMouseWheel(event:MouseEvent):void
Event handler so FlxGame can update the mouse.
Mouse
  
hide():void
Hides the mouse cursor
Mouse
  
justPressed():Boolean
Check to see if the mouse was just pressed.
Mouse
  
justReleased():Boolean
Check to see if the mouse was just released.
Mouse
  
load(Graphic:Class = null, Scale:Number = 1, XOffset:int = 0, YOffset:int = 0):void
Load a new mouse cursor graphic
Mouse
 Inherited
make(X:Number = 0, Y:Number = 0):FlxPoint
Instantiate a new point object.
FlxPoint
  
playback(Record:MouseRecord):void
Part of the keystroke recording system.
Mouse
  
pressed():Boolean
Check to see if the mouse is pressed.
Mouse
  
If the mouse changed state or is pressed, return that info now
Mouse
  
reset():void
Resets the just pressed/just released flags and sets mouse to not pressed.
Mouse
  
show(Graphic:Class = null, Scale:Number = 1, XOffset:int = 0, YOffset:int = 0):void
Either show an existing cursor or load a new one.
Mouse
  
unload():void
Unload the current cursor graphic.
Mouse
  
update(X:int, Y:int):void
Called by the internal game loop to update the mouse pointer's position in the game world.
Mouse
Protected Methods
 MethodDefined By
  
Internal function for helping to update the mouse cursor and world coordinates.
Mouse
Property Detail
_currentproperty
protected var _current:int

Helper variable for tracking whether the mouse was just pressed or just released.

_cursorproperty 
protected var _cursor:Bitmap

This is just a reference to the current cursor image, if there is one.

_cursorContainerproperty 
protected var _cursorContainer:Sprite

A display container for the mouse cursor. This container is a child of FlxGame and sits at the right "height".

_lastproperty 
protected var _last:int

Helper variable for tracking whether the mouse was just pressed or just released.

_lastWheelproperty 
protected var _lastWheel:int

_lastXproperty 
protected var _lastX:int

Helper variables for recording purposes.

_lastYproperty 
protected var _lastY:int

_outproperty 
protected var _out:Boolean

Helper for mouse visibility.

_pointproperty 
protected var _point:FlxPoint

_screenPositionproperty 
protected var _screenPosition:FlxPoint

ImgDefaultCursorproperty 
protected var ImgDefaultCursor:Class

screenXproperty 
public var screenX:int

Current X position of the mouse pointer on the screen.

screenYproperty 
public var screenY:int

Current Y position of the mouse pointer on the screen.

visibleproperty 
visible:Boolean  [read-only]


Implementation
    public function get visible():Boolean
wheelproperty 
public var wheel:int

Current "delta" value of mouse wheel. If the wheel was just scrolled up, it will have a positive value. If it was just scrolled down, it will have a negative value. If it wasn't just scroll this frame, it will be 0.

Constructor Detail
Mouse()Constructor
public function Mouse(CursorContainer:Sprite)

Constructor.

Parameters
CursorContainer:Sprite
Method Detail
destroy()method
public function destroy():void

getScreenPosition()method 
public function getScreenPosition(Camera:FlxCamera = null, Point:FlxPoint = null):FlxPoint

Parameters

Camera:FlxCamera (default = null)
 
Point:FlxPoint (default = null)

Returns
FlxPoint
getWorldPosition()method 
public function getWorldPosition(Camera:FlxCamera = null, Point:FlxPoint = null):FlxPoint

Parameters

Camera:FlxCamera (default = null)
 
Point:FlxPoint (default = null)

Returns
FlxPoint
handleMouseDown()method 
public function handleMouseDown(event:MouseEvent):void

Event handler so FlxGame can update the mouse.

Parameters

event:MouseEvent — A MouseEvent object.

handleMouseOut()method 
public function handleMouseOut(event:MouseEvent):void

Event handler so FlxGame can update the mouse.

Parameters

event:MouseEvent — A MouseEvent object.

handleMouseOver()method 
public function handleMouseOver(event:MouseEvent):void

Event handler so FlxGame can update the mouse.

Parameters

event:MouseEvent — A MouseEvent object.

handleMouseUp()method 
public function handleMouseUp(event:MouseEvent):void

Event handler so FlxGame can update the mouse.

Parameters

event:MouseEvent — A MouseEvent object.

handleMouseWheel()method 
public function handleMouseWheel(event:MouseEvent):void

Event handler so FlxGame can update the mouse.

Parameters

event:MouseEvent — A MouseEvent object.

hide()method 
public function hide():void

Hides the mouse cursor

justPressed()method 
public function justPressed():Boolean

Check to see if the mouse was just pressed.

Returns
Boolean — Whether the mouse was just pressed.
justReleased()method 
public function justReleased():Boolean

Check to see if the mouse was just released.

Returns
Boolean — Whether the mouse was just released.
load()method 
public function load(Graphic:Class = null, Scale:Number = 1, XOffset:int = 0, YOffset:int = 0):void

Load a new mouse cursor graphic

Parameters

Graphic:Class (default = null) — The image you want to use for the cursor.
 
Scale:Number (default = 1) — Change the size of the cursor.
 
XOffset:int (default = 0) — The number of pixels between the mouse's screen position and the graphic's top left corner.
 
YOffset:int (default = 0) — The number of pixels between the mouse's screen position and the graphic's top left corner.

playback()method 
public function playback(Record:MouseRecord):void

Part of the keystroke recording system. Takes data about key presses and sets it into array.

Parameters

Record:MouseRecord — Array of data about key states.

pressed()method 
public function pressed():Boolean

Check to see if the mouse is pressed.

Returns
Boolean — Whether the mouse is pressed.
record()method 
public function record():MouseRecord

If the mouse changed state or is pressed, return that info now

Returns
MouseRecord — An array of key state data. Null if there is no data.
reset()method 
public function reset():void

Resets the just pressed/just released flags and sets mouse to not pressed.

show()method 
public function show(Graphic:Class = null, Scale:Number = 1, XOffset:int = 0, YOffset:int = 0):void

Either show an existing cursor or load a new one.

Parameters

Graphic:Class (default = null) — The image you want to use for the cursor.
 
Scale:Number (default = 1) — Change the size of the cursor. Default = 1, or native size. 2 = 2x as big, 0.5 = half size, etc.
 
XOffset:int (default = 0) — The number of pixels between the mouse's screen position and the graphic's top left corner.
 
YOffset:int (default = 0) — The number of pixels between the mouse's screen position and the graphic's top left corner.

unload()method 
public function unload():void

Unload the current cursor graphic. If the current cursor is visible, then the default system cursor is loaded up to replace the old one.

update()method 
public function update(X:int, Y:int):void

Called by the internal game loop to update the mouse pointer's position in the game world. Also updates the just pressed/just released flags.

Parameters

X:int — The current X position of the mouse in the window.
 
Y:int — The current Y position of the mouse in the window.

updateCursor()method 
protected function updateCursor():void

Internal function for helping to update the mouse cursor and world coordinates.