Packageorg.flixel
Classpublic class FlxSprite
InheritanceFlxSprite Inheritance FlxObject Inheritance FlxBasic Inheritance Object
Subclasses FlxButton, FlxParticle, FlxText, FlxTileblock

The main "game object" class, the sprite is a FlxObject with a bunch of graphics options and abilities, like animation and stamping.



Public Properties
 PropertyDefined By
 Inheritedacceleration : FlxPoint
How fast the speed of this object is changing.
FlxObject
 Inheritedactive : Boolean
Controls whether update() is automatically called by FlxState/FlxGroup.
FlxBasic
 Inherited_ACTIVECOUNT : uint
[static]
FlxBasic
 Inheritedalive : Boolean
Useful state for many game objects - "dead" (!alive) vs alive.
FlxBasic
 InheritedallowCollisions : uint
Bit field of flags (use with UP, DOWN, LEFT, RIGHT, etc) indicating collision directions.
FlxObject
  alpha : Number
Set alpha to a number between 0 and 1 to change the opacity of the sprite.
FlxSprite
 Inheritedangle : Number
Set the angle of a sprite to rotate it.
FlxObject
 InheritedangularAcceleration : Number
How fast the spin speed should change.
FlxObject
 InheritedangularDrag : Number
Like drag but for spinning.
FlxObject
 InheritedangularVelocity : Number
This is how fast you want this sprite to spin.
FlxObject
  antialiasing : Boolean
Controls whether the object is smoothed when rotated, affects performance.
FlxSprite
  blend : String
Blending modes, just like Photoshop or whatever.
FlxSprite
 Inheritedcameras : Array
An array of camera objects that this object will use during draw().
FlxBasic
  color : uint
Set color to a number in this format: 0xRRGGBB.
FlxSprite
  dirty : Boolean
Set this flag to true to force the sprite to update during the draw() call.
FlxSprite
 Inheriteddrag : FlxPoint
This isn't drag exactly, more like deceleration that is only applied when acceleration is not affecting the sprite.
FlxObject
 Inheritedelasticity : Number
The bounciness of this object.
FlxObject
 Inheritedexists : Boolean
Controls whether update() and draw() are automatically called by FlxState/FlxGroup.
FlxBasic
  facing : uint
Set facing using FlxSprite.LEFT,RIGHT, UP, and DOWN to take advantage of flipped sprites and/or just track player orientation more easily.
FlxSprite
  finished : Boolean
Whether the current animation has finished its first (or only) loop.
FlxSprite
 Inheritedflickering : Boolean
[read-only] Check to see if the object is still flickering.
FlxObject
  frame : uint
Tell the sprite to change to a specific frame of animation.
FlxSprite
  frameHeight : uint
The height of the actual graphic or image being displayed (not necessarily the game object/bounding box).
FlxSprite
  framePixels : BitmapData
The actual Flash BitmapData object representing the current display state of the sprite.
FlxSprite
  frames : uint
The total number of frames in this image.
FlxSprite
  frameWidth : uint
The width of the actual graphic or image being displayed (not necessarily the game object/bounding box).
FlxSprite
 Inheritedhealth : Number
Handy for storing health percentage or armor points or whatever.
FlxObject
 Inheritedheight : Number
The height of this object.
FlxObject
 InheritedID : int
IDs seem like they could be pretty useful, huh? They're not actually used for anything yet though.
FlxBasic
 InheritedignoreDrawDebug : Boolean
Setting this to true will prevent the object from appearing when the visual debug mode in the debugger overlay is toggled on.
FlxBasic
 Inheritedimmovable : Boolean
Whether an object will move/alter position after a collision.
FlxObject
 Inheritedlast : FlxPoint
Important variable for collision processing.
FlxObject
 Inheritedmass : Number
The virtual mass of the object.
FlxObject
 InheritedmaxAngular : Number
Use in conjunction with angularAcceleration for fluid spin speed control.
FlxObject
 InheritedmaxVelocity : FlxPoint
If you are using acceleration, you can use maxVelocity with it to cap the speed automatically (very useful!).
FlxObject
 Inheritedmoves : Boolean
Set this to false if you want to skip the automatic motion/movement stuff (see updateMotion()).
FlxObject
  offset : FlxPoint
If you changed the size of your sprite object after loading or making the graphic, you might need to offset the graphic away from the bound box to center it the way you want.
FlxSprite
  origin : FlxPoint
WARNING: The origin of the sprite will default to its center.
FlxSprite
 Inheritedpath : FlxPath
A reference to a path object.
FlxObject
 InheritedpathAngle : Number
The angle in degrees between this object and the next node, where 0 is directly upward, and 90 is to the right.
FlxObject
 InheritedpathSpeed : Number
The speed at which the object is moving on the path.
FlxObject
  pixels : BitmapData
Set pixels to any BitmapData object.
FlxSprite
  scale : FlxPoint
Change the size of your sprite's graphic.
FlxSprite
 InheritedscrollFactor : FlxPoint
A point that can store numbers from 0 to 1 (for X and Y independently) that governs how much this object is affected by the camera subsystem.
FlxObject
 Inheritedsolid : Boolean
Whether the object collides or not.
FlxObject
 Inheritedtouching : uint
Bit field of flags (use with UP, DOWN, LEFT, RIGHT, etc) indicating surface contacts.
FlxObject
 Inheritedvelocity : FlxPoint
The basic speed of this object.
FlxObject
 Inheritedvisible : Boolean
Controls whether draw() is automatically called by FlxState/FlxGroup.
FlxBasic
 Inherited_VISIBLECOUNT : uint
[static]
FlxBasic
 InheritedwasTouching : uint
Bit field of flags (use with UP, DOWN, LEFT, RIGHT, etc) indicating surface contacts from the previous game loop step.
FlxObject
 Inheritedwidth : Number
The width of this object.
FlxObject
 Inheritedx : Number
X position of the upper left corner of this object in world space.
FlxObject
 Inheritedy : Number
Y position of the upper left corner of this object in world space.
FlxObject
Protected Properties
 PropertyDefined By
  _alpha : Number
Internal tracker for opacity, used with Flash getter/setter.
FlxSprite
  _animations : Array
Internal, stores all the animations that were added to this sprite.
FlxSprite
  _bakedRotation : Number
Internal tracker for how many frames of "baked" rotation there are (if any).
FlxSprite
  _callback : Function
Internal tracker for the animation callback.
FlxSprite
  _color : uint
Internal tracker for color tint, used with Flash getter/setter.
FlxSprite
  _colorTransform : ColorTransform
Internal, helps with animation, caching and drawing.
FlxSprite
  _curAnim : FlxAnim
Internal, keeps track of the current animation being played.
FlxSprite
  _curFrame : uint
Internal, keeps track of the current frame of animation.
FlxSprite
  _curIndex : uint
Internal, keeps track of the current index into the tile sheet based on animation or rotation.
FlxSprite
  _facing : uint
Internal tracker for what direction the sprite is currently facing, used with Flash getter/setter.
FlxSprite
  _flashPoint : Point
Internal, reused frequently during drawing and animating.
FlxSprite
  _flashPointZero : Point
Internal, reused frequently during drawing and animating.
FlxSprite
  _flashRect : Rectangle
Internal, reused frequently during drawing and animating.
FlxSprite
  _flashRect2 : Rectangle
Internal, reused frequently during drawing and animating.
FlxSprite
 Inherited_flicker : Boolean
Internal helper used for retro-style flickering.
FlxObject
 Inherited_flickerTimer : Number
Internal helper used for retro-style flickering.
FlxObject
  _flipped : uint
Internal, keeps track of whether the sprite was loaded with support for automatic reverse/mirroring.
FlxSprite
  _frameTimer : Number
Internal, used to time each frame of animation.
FlxSprite
  ImgDefault : Class
FlxSprite
  _matrix : Matrix
Internal, helps with animation, caching and drawing.
FlxSprite
 Inherited_pathInc : int
Internal helper for node navigation, specifically yo-yo and backwards movement.
FlxObject
 Inherited_pathMode : uint
Internal tracker for path behavior flags (like looping, horizontal only, etc).
FlxObject
 Inherited_pathNodeIndex : int
Internal helper, tracks which node of the path this object is moving toward.
FlxObject
 Inherited_pathRotate : Boolean
Internal flag for whether hte object's angle should be adjusted to the path angle during path follow behavior.
FlxObject
  _pixels : BitmapData
Internal, stores the entire source graphic (not the current displayed animation frame), used with Flash getter/setter.
FlxSprite
 Inherited_point : FlxPoint
This is just a pre-allocated x-y point container to be used however you like
FlxObject
 Inherited_rect : FlxRect
This is just a pre-allocated rectangle container to be used however you like
FlxObject
Public Methods
 MethodDefined By
  
FlxSprite(X:Number = 0, Y:Number = 0, SimpleGraphic:Class = null)
Creates a white 8x8 square FlxSprite at the specified position.
FlxSprite
  
addAnimation(Name:String, Frames:Array, FrameRate:Number = 0, Looped:Boolean = true):void
Adds a new animation to the sprite.
FlxSprite
  
addAnimationCallback(AnimationCallback:Function):void
Pass in a function to be called whenever this sprite's animation changes.
FlxSprite
  
centerOffsets(AdjustPosition:Boolean = false):void
Helper function that adjusts the offset automatically to center the bounding box within the graphic.
FlxSprite
  
destroy():void
[override] Clean up memory.
FlxSprite
  
draw():void
[override] Called by game loop, updates then blits or renders current frame of animation to the screen
FlxSprite
 Inherited
drawDebug(Camera:FlxCamera = null):void
[override] Override this function to draw custom "debug mode" graphics to the specified camera while the debugger's visual mode is toggled on.
FlxObject
  
drawFrame(Force:Boolean = false):void
Request (or force) that the sprite update the frame before rendering.
FlxSprite
  
drawLine(StartX:Number, StartY:Number, EndX:Number, EndY:Number, Color:uint, Thickness:uint = 1):void
This function draws a line on this sprite from position X1,Y1 to position X2,Y2 with the specified color.
FlxSprite
  
fill(Color:uint):void
Fills this sprite's graphic with a specific color.
FlxSprite
 Inherited
flicker(Duration:Number = 1):void
Tells this object to flicker, retro-style.
FlxObject
 Inherited
followPath(Path:FlxPath, Speed:Number = 100, Mode:uint, AutoRotate:Boolean = false):void
Call this function to give this object a path to follow.
FlxObject
 Inherited
Retrieve the midpoint of this object in world coordinates.
FlxObject
 Inherited
getScreenXY(Point:FlxPoint = null, Camera:FlxCamera = null):FlxPoint
Call this function to figure out the on-screen position of the object.
FlxObject
 Inherited
hurt(Damage:Number):void
Reduces the "health" variable of this sprite by the amount specified in Damage.
FlxObject
 Inherited
isTouching(Direction:uint):Boolean
Handy function for checking if this object is touching a particular surface.
FlxObject
 Inherited
justTouched(Direction:uint):Boolean
Handy function for checking if this object is just landed on a particular surface.
FlxObject
 Inherited
kill():void
Handy function for "killing" game objects.
FlxBasic
  
loadGraphic(Graphic:Class, Animated:Boolean = false, Reverse:Boolean = false, Width:uint = 0, Height:uint = 0, Unique:Boolean = false):FlxSprite
Load an image from an embedded graphic file.
FlxSprite
  
loadRotatedGraphic(Graphic:Class, Rotations:uint = 16, Frame:int = -1, AntiAliasing:Boolean = false, AutoBuffer:Boolean = false):FlxSprite
Create a pre-rotated sprite sheet from a simple sprite.
FlxSprite
  
makeGraphic(Width:uint, Height:uint, Color:uint = 0xffffffff, Unique:Boolean = false, Key:String = null):FlxSprite
This function creates a flat colored square image dynamically.
FlxSprite
  
onScreen(Camera:FlxCamera = null):Boolean
[override] Check and see if this object is currently on screen.
FlxSprite
 Inherited
overlaps(ObjectOrGroup:FlxBasic, InScreenSpace:Boolean = false, Camera:FlxCamera = null):Boolean
Checks to see if some FlxObject overlaps this FlxObject or FlxGroup.
FlxObject
 Inherited
overlapsAt(X:Number, Y:Number, ObjectOrGroup:FlxBasic, InScreenSpace:Boolean = false, Camera:FlxCamera = null):Boolean
Checks to see if this FlxObject were located at the given position, would it overlap the FlxObject or FlxGroup? This is distinct from overlapsPoint(), which just checks that point, rather than taking the object's size into account.
FlxObject
 Inherited
overlapsPoint(Point:FlxPoint, InScreenSpace:Boolean = false, Camera:FlxCamera = null):Boolean
Checks to see if a point in 2D world space overlaps this FlxObject object.
FlxObject
  
pixelsOverlapPoint(Point:FlxPoint, Mask:uint = 0xFF, Camera:FlxCamera = null):Boolean
Checks to see if a point in 2D world space overlaps this FlxSprite object's current displayed pixels.
FlxSprite
  
play(AnimName:String, Force:Boolean = false):void
Plays an existing animation (e.g.
FlxSprite
  
postUpdate():void
[override] Automatically called after update() by the game loop, this function just calls updateAnimation().
FlxSprite
 Inherited
preUpdate():void
[override] Pre-update is called right before update() on each object in the game loop.
FlxObject
  
Tell the sprite to change to a random frame of animation Useful for instantiating particles or other weird things.
FlxSprite
  
replaceColor(Color:uint, NewColor:uint, FetchPositions:Boolean = false):Array
FlxSprite
 Inherited
reset(X:Number, Y:Number):void
Handy function for reviving game objects.
FlxObject
 Inherited
revive():void
Handy function for bringing game objects "back to life".
FlxBasic
 Inherited
separate(Object1:FlxObject, Object2:FlxObject):Boolean
[static] The main collision resolution function in flixel.
FlxObject
 Inherited
separateX(Object1:FlxObject, Object2:FlxObject):Boolean
[static] The X-axis component of the object separation process.
FlxObject
 Inherited
separateY(Object1:FlxObject, Object2:FlxObject):Boolean
[static] The Y-axis component of the object separation process.
FlxObject
  
Helper function that just sets origin to (0,0)
FlxSprite
  
stamp(Brush:FlxSprite, X:int = 0, Y:int = 0):void
This function draws or stamps one FlxSprite onto another.
FlxSprite
 Inherited
stopFollowingPath(DestroyPath:Boolean = false):void
Tells this object to stop following the path its on.
FlxObject
 Inherited
toString():String
Convert object to readable string name.
FlxBasic
 Inherited
update():void
Override this function to update your class's position and appearance.
FlxBasic
Protected Methods
 MethodDefined By
 Inherited
advancePath(Snap:Boolean = true):FlxPoint
Internal function that decides what node in the path to aim for next based on the behavior flags.
FlxObject
  
calcFrame():void
Internal function to update the current animation frame.
FlxSprite
  
Resets some important variables for sprite optimization and rendering.
FlxSprite
  
Internal function for updating the sprite's animation.
FlxSprite
 Inherited
Internal function for updating the position and speed of this object.
FlxObject
 Inherited
Internal function for moving the object along the path.
FlxObject
Public Constants
 ConstantDefined By
 InheritedANY : uint
[static] Special-case constant meaning any direction, used mainly by allowCollisions and touching.
FlxObject
 InheritedCEILING : uint = 0x0100
[static] Special-case constant meaning up, used mainly by allowCollisions and touching.
FlxObject
 InheritedDOWN : uint = 0x1000
[static] Generic value for "down" Used by facing, allowCollisions, and touching.
FlxObject
 InheritedFLOOR : uint = 0x1000
[static] Special-case constant meaning down, used mainly by allowCollisions and touching.
FlxObject
 InheritedLEFT : uint = 0x0001
[static] Generic value for "left" Used by facing, allowCollisions, and touching.
FlxObject
 InheritedNONE : uint = 0
[static] Special-case constant meaning no collisions, used mainly by allowCollisions and touching.
FlxObject
 InheritedOVERLAP_BIAS : Number = 4
[static] Handy constant used during collision resolution (see separateX() and separateY()).
FlxObject
 InheritedPATH_BACKWARD : uint = 0x000001
[static] Path behavior controls: move from the end of the path to the start then stop.
FlxObject
 InheritedPATH_FORWARD : uint = 0x000000
[static] Path behavior controls: move from the start of the path to the end then stop.
FlxObject
 InheritedPATH_HORIZONTAL_ONLY : uint = 0x010000
[static] Path behavior controls: ignores any vertical component to the path data, only follows side to side.
FlxObject
 InheritedPATH_LOOP_BACKWARD : uint = 0x000100
[static] Path behavior controls: move from the end of the path to the start then directly back to the end, and start over.
FlxObject
 InheritedPATH_LOOP_FORWARD : uint = 0x000010
[static] Path behavior controls: move from the start of the path to the end then directly back to the start, and start over.
FlxObject
 InheritedPATH_VERTICAL_ONLY : uint = 0x100000
[static] Path behavior controls: ignores any horizontal component to the path data, only follows up and down.
FlxObject
 InheritedPATH_YOYO : uint = 0x001000
[static] Path behavior controls: move from the start of the path to the end then turn around and go back to the start, over and over.
FlxObject
 InheritedRIGHT : uint = 0x0010
[static] Generic value for "right" Used by facing, allowCollisions, and touching.
FlxObject
 InheritedUP : uint = 0x0100
[static] Generic value for "up" Used by facing, allowCollisions, and touching.
FlxObject
 InheritedWALL : uint
[static] Special-case constant meaning only the left and right sides, used mainly by allowCollisions and touching.
FlxObject
Protected Constants
 ConstantDefined By
 Inherited_pZero : FlxPoint
[static] Should always represent (0,0) - useful for different things, for avoiding unnecessary new calls.
FlxObject
Property Detail
_alphaproperty
protected var _alpha:Number

Internal tracker for opacity, used with Flash getter/setter.

_animationsproperty 
protected var _animations:Array

Internal, stores all the animations that were added to this sprite.

_bakedRotationproperty 
protected var _bakedRotation:Number

Internal tracker for how many frames of "baked" rotation there are (if any).

_callbackproperty 
protected var _callback:Function

Internal tracker for the animation callback. Default is null. If assigned, will be called each time the current frame changes. A function that has 3 parameters: a string name, a uint frame number, and a uint frame index.

_colorproperty 
protected var _color:uint

Internal tracker for color tint, used with Flash getter/setter.

_colorTransformproperty 
protected var _colorTransform:ColorTransform

Internal, helps with animation, caching and drawing.

_curAnimproperty 
protected var _curAnim:FlxAnim

Internal, keeps track of the current animation being played.

_curFrameproperty 
protected var _curFrame:uint

Internal, keeps track of the current frame of animation. This is NOT an index into the tile sheet, but the frame number in the animation object.

_curIndexproperty 
protected var _curIndex:uint

Internal, keeps track of the current index into the tile sheet based on animation or rotation.

_facingproperty 
protected var _facing:uint

Internal tracker for what direction the sprite is currently facing, used with Flash getter/setter.

_flashPointproperty 
protected var _flashPoint:Point

Internal, reused frequently during drawing and animating.

_flashPointZeroproperty 
protected var _flashPointZero:Point

Internal, reused frequently during drawing and animating. Always contains (0,0).

_flashRectproperty 
protected var _flashRect:Rectangle

Internal, reused frequently during drawing and animating.

_flashRect2property 
protected var _flashRect2:Rectangle

Internal, reused frequently during drawing and animating.

_flippedproperty 
protected var _flipped:uint

Internal, keeps track of whether the sprite was loaded with support for automatic reverse/mirroring.

_frameTimerproperty 
protected var _frameTimer:Number

Internal, used to time each frame of animation.

_matrixproperty 
protected var _matrix:Matrix

Internal, helps with animation, caching and drawing.

_pixelsproperty 
protected var _pixels:BitmapData

Internal, stores the entire source graphic (not the current displayed animation frame), used with Flash getter/setter.

alphaproperty 
alpha:Number

Set alpha to a number between 0 and 1 to change the opacity of the sprite.


Implementation
    public function get alpha():Number
    public function set alpha(value:Number):void
antialiasingproperty 
public var antialiasing:Boolean

Controls whether the object is smoothed when rotated, affects performance.

The default value is false.

blendproperty 
public var blend:String

Blending modes, just like Photoshop or whatever. E.g. "multiply", "screen", etc.

The default value is null.

colorproperty 
color:uint

Set color to a number in this format: 0xRRGGBB. color IGNORES ALPHA. To change the opacity use alpha. Tints the whole sprite to be this color (similar to OpenGL vertex colors).


Implementation
    public function get color():uint
    public function set color(value:uint):void
dirtyproperty 
public var dirty:Boolean

Set this flag to true to force the sprite to update during the draw() call. NOTE: Rarely if ever necessary, most sprite operations will flip this flag automatically.

facingproperty 
facing:uint

Set facing using FlxSprite.LEFT,RIGHT, UP, and DOWN to take advantage of flipped sprites and/or just track player orientation more easily.


Implementation
    public function get facing():uint
    public function set facing(value:uint):void
finishedproperty 
public var finished:Boolean

Whether the current animation has finished its first (or only) loop.

frameproperty 
frame:uint

Tell the sprite to change to a specific frame of animation.


Implementation
    public function get frame():uint
    public function set frame(value:uint):void
frameHeightproperty 
public var frameHeight:uint

The height of the actual graphic or image being displayed (not necessarily the game object/bounding box). NOTE: Edit at your own risk!! This is intended to be read-only.

framePixelsproperty 
public var framePixels:BitmapData

The actual Flash BitmapData object representing the current display state of the sprite.

framesproperty 
public var frames:uint

The total number of frames in this image. WARNING: assumes each row in the sprite sheet is full!

frameWidthproperty 
public var frameWidth:uint

The width of the actual graphic or image being displayed (not necessarily the game object/bounding box). NOTE: Edit at your own risk!! This is intended to be read-only.

ImgDefaultproperty 
protected var ImgDefault:Class

offsetproperty 
public var offset:FlxPoint

If you changed the size of your sprite object after loading or making the graphic, you might need to offset the graphic away from the bound box to center it the way you want.

originproperty 
public var origin:FlxPoint

WARNING: The origin of the sprite will default to its center. If you change this, the visuals and the collisions will likely be pretty out-of-sync if you do any rotation.

pixelsproperty 
pixels:BitmapData

Set pixels to any BitmapData object. Automatically adjust graphic size and render helpers.


Implementation
    public function get pixels():BitmapData
    public function set pixels(value:BitmapData):void
scaleproperty 
public var scale:FlxPoint

Change the size of your sprite's graphic. NOTE: Scale doesn't currently affect collisions automatically, you will need to adjust the width, height and offset manually. WARNING: scaling sprites decreases rendering performance for this sprite by a factor of 10x!

Constructor Detail
FlxSprite()Constructor
public function FlxSprite(X:Number = 0, Y:Number = 0, SimpleGraphic:Class = null)

Creates a white 8x8 square FlxSprite at the specified position. Optionally can load a simple, one-frame graphic instead.

Parameters
X:Number (default = 0) — The initial X position of the sprite.
 
Y:Number (default = 0) — The initial Y position of the sprite.
 
SimpleGraphic:Class (default = null) — The graphic you want to display (OPTIONAL - for simple stuff only, do NOT use for animated images!).
Method Detail
addAnimation()method
public function addAnimation(Name:String, Frames:Array, FrameRate:Number = 0, Looped:Boolean = true):void

Adds a new animation to the sprite.

Parameters

Name:String — What this animation should be called (e.g. "run").
 
Frames:Array — An array of numbers indicating what frames to play in what order (e.g. 1, 2, 3).
 
FrameRate:Number (default = 0) — The speed in frames per second that the animation should play at (e.g. 40 fps).
 
Looped:Boolean (default = true) — Whether or not the animation is looped or just plays once.

addAnimationCallback()method 
public function addAnimationCallback(AnimationCallback:Function):void

Pass in a function to be called whenever this sprite's animation changes.

Parameters

AnimationCallback:Function — A function that has 3 parameters: a string name, a uint frame number, and a uint frame index.

calcFrame()method 
protected function calcFrame():void

Internal function to update the current animation frame.

centerOffsets()method 
public function centerOffsets(AdjustPosition:Boolean = false):void

Helper function that adjusts the offset automatically to center the bounding box within the graphic.

Parameters

AdjustPosition:Boolean (default = false) — Adjusts the actual X and Y position just once to match the offset change. Default is false.

destroy()method 
override public function destroy():void

Clean up memory.

draw()method 
override public function draw():void

Called by game loop, updates then blits or renders current frame of animation to the screen

drawFrame()method 
public function drawFrame(Force:Boolean = false):void

Request (or force) that the sprite update the frame before rendering. Useful if you are doing procedural generation or other weirdness!

Parameters

Force:Boolean (default = false) — Force the frame to redraw, even if its not flagged as necessary.

drawLine()method 
public function drawLine(StartX:Number, StartY:Number, EndX:Number, EndY:Number, Color:uint, Thickness:uint = 1):void

This function draws a line on this sprite from position X1,Y1 to position X2,Y2 with the specified color.

Parameters

StartX:Number — X coordinate of the line's start point.
 
StartY:Number — Y coordinate of the line's start point.
 
EndX:Number — X coordinate of the line's end point.
 
EndY:Number — Y coordinate of the line's end point.
 
Color:uint — The line's color.
 
Thickness:uint (default = 1) — How thick the line is in pixels (default value is 1).

fill()method 
public function fill(Color:uint):void

Fills this sprite's graphic with a specific color.

Parameters

Color:uint — The color with which to fill the graphic, format 0xAARRGGBB.

loadGraphic()method 
public function loadGraphic(Graphic:Class, Animated:Boolean = false, Reverse:Boolean = false, Width:uint = 0, Height:uint = 0, Unique:Boolean = false):FlxSprite

Load an image from an embedded graphic file.

Parameters

Graphic:Class — The image you want to use.
 
Animated:Boolean (default = false) — Whether the Graphic parameter is a single sprite or a row of sprites.
 
Reverse:Boolean (default = false) — Whether you need this class to generate horizontally flipped versions of the animation frames.
 
Width:uint (default = 0) — Optional, specify the width of your sprite (helps FlxSprite figure out what to do with non-square sprites or sprite sheets).
 
Height:uint (default = 0) — Optional, specify the height of your sprite (helps FlxSprite figure out what to do with non-square sprites or sprite sheets).
 
Unique:Boolean (default = false) — Optional, whether the graphic should be a unique instance in the graphics cache. Default is false.

Returns
FlxSprite — This FlxSprite instance (nice for chaining stuff together, if you're into that).
loadRotatedGraphic()method 
public function loadRotatedGraphic(Graphic:Class, Rotations:uint = 16, Frame:int = -1, AntiAliasing:Boolean = false, AutoBuffer:Boolean = false):FlxSprite

Create a pre-rotated sprite sheet from a simple sprite. This can make a huge difference in graphical performance!

Parameters

Graphic:Class — The image you want to rotate and stamp.
 
Rotations:uint (default = 16) — The number of rotation frames the final sprite should have. For small sprites this can be quite a large number (360 even) without any problems.
 
Frame:int (default = -1) — If the Graphic has a single row of square animation frames on it, you can specify which of the frames you want to use here. Default is -1, or "use whole graphic."
 
AntiAliasing:Boolean (default = false) — Whether to use high quality rotations when creating the graphic. Default is false.
 
AutoBuffer:Boolean (default = false) — Whether to automatically increase the image size to accomodate rotated corners. Default is false. Will create frames that are 150% larger on each axis than the original frame or graphic.

Returns
FlxSprite — This FlxSprite instance (nice for chaining stuff together, if you're into that).
makeGraphic()method 
public function makeGraphic(Width:uint, Height:uint, Color:uint = 0xffffffff, Unique:Boolean = false, Key:String = null):FlxSprite

This function creates a flat colored square image dynamically.

Parameters

Width:uint — The width of the sprite you want to generate.
 
Height:uint — The height of the sprite you want to generate.
 
Color:uint (default = 0xffffffff) — Specifies the color of the generated block.
 
Unique:Boolean (default = false) — Whether the graphic should be a unique instance in the graphics cache. Default is false.
 
Key:String (default = null) — Optional parameter - specify a string key to identify this graphic in the cache. Trumps Unique flag.

Returns
FlxSprite — This FlxSprite instance (nice for chaining stuff together, if you're into that).
onScreen()method 
override public function onScreen(Camera:FlxCamera = null):Boolean

Check and see if this object is currently on screen. Differs from FlxObject's implementation in that it takes the actual graphic into account, not just the hitbox or bounding box or whatever.

Parameters

Camera:FlxCamera (default = null) — Specify which game camera you want. If null getScreenXY() will just grab the first global camera.

Returns
Boolean — Whether the object is on screen or not.
pixelsOverlapPoint()method 
public function pixelsOverlapPoint(Point:FlxPoint, Mask:uint = 0xFF, Camera:FlxCamera = null):Boolean

Checks to see if a point in 2D world space overlaps this FlxSprite object's current displayed pixels. This check is ALWAYS made in screen space, and always takes scroll factors into account.

Parameters

Point:FlxPoint — The point in world space you want to check.
 
Mask:uint (default = 0xFF) — Used in the pixel hit test to determine what counts as solid.
 
Camera:FlxCamera (default = null) — Specify which game camera you want. If null getScreenXY() will just grab the first global camera.

Returns
Boolean — Whether or not the point overlaps this object.
play()method 
public function play(AnimName:String, Force:Boolean = false):void

Plays an existing animation (e.g. "run"). If you call an animation that is already playing it will be ignored.

Parameters

AnimName:String — The string name of the animation you want to play.
 
Force:Boolean (default = false) — Whether to force the animation to restart.

postUpdate()method 
override public function postUpdate():void

Automatically called after update() by the game loop, this function just calls updateAnimation().

randomFrame()method 
public function randomFrame():void

Tell the sprite to change to a random frame of animation Useful for instantiating particles or other weird things.

replaceColor()method 
public function replaceColor(Color:uint, NewColor:uint, FetchPositions:Boolean = false):Array

Parameters

Color:uint
 
NewColor:uint
 
FetchPositions:Boolean (default = false)

Returns
Array
resetHelpers()method 
protected function resetHelpers():void

Resets some important variables for sprite optimization and rendering.

setOriginToCorner()method 
public function setOriginToCorner():void

Helper function that just sets origin to (0,0)

stamp()method 
public function stamp(Brush:FlxSprite, X:int = 0, Y:int = 0):void

This function draws or stamps one FlxSprite onto another. This function is NOT intended to replace draw()!

Parameters

Brush:FlxSprite — The image you want to use as a brush or stamp or pen or whatever.
 
X:int (default = 0) — The X coordinate of the brush's top left corner on this sprite.
 
Y:int (default = 0) — They Y coordinate of the brush's top left corner on this sprite.

updateAnimation()method 
protected function updateAnimation():void

Internal function for updating the sprite's animation. Useful for cases when you need to update this but are buried down in too many supers. This function is called automatically by FlxSprite.postUpdate().