Packageflare.display
Classpublic class DirtySprite
InheritanceDirtySprite Inheritance flash.display.Sprite
SubclassesDataSprite, LineSprite, RectSprite, TextSprite

A Sprite that redraws itself as needed when marked as "dirty". This allows multiple changes to be made to the sprite between frames without triggering a potentially costly redraw for each property update. Instead, the dirty() method should be called whenever a change is made to the Sprite that would normally require a redraw. This class will ensure that the Sprite is redrawn only once before the next frame is rendered.

Subclasses should place drawing code within the render() method. For all properties used by the render method to help draw this sprite, the corresponding "setter" method should call the dirty() method to mark the sprite as dirty and thereby trigger a redraw for the next frame.

Internally, the DirtySprite class maintains a static list of all "dirty" sprites, and redraws each sprite in the list when a Event.RENDER event is issued. Typically, this process is performed automatically. In a few cases, erratic behavior has been observed due to a Flash Player bug that results in RENDER events not being properly issued. As a fallback, the static renderDirty() method can be invoked to manually force each dirty sprite to be redrawn.



Public Properties
 PropertyDefined by
  angle : Number
The angle value of this sprite's position in polar co-ordinates.
DirtySprite
  height : Number
[read-only] If dirty, this sprite is re-rendered before returning the height.
DirtySprite
  origin : Point
The origin point for polar coordinates.
DirtySprite
  radius : Number
The radius value of this sprite's position in polar co-ordinates.
DirtySprite
  width : Number
[read-only] If dirty, this sprite is re-rendered before returning the width.
DirtySprite
  x : Number
[write-only]
DirtySprite
  y : Number
[write-only]
DirtySprite
Protected Properties
 PropertyDefined by
  _angle : Number
The angle value of this sprite's position in polar co-ordinates.
DirtySprite
  _origin : Point
The origin point for polar coordinates.
DirtySprite
  _radius : Number
The radius value of this sprite's position in polar co-ordinates.
DirtySprite
Public Methods
 MethodDefined by
  
Creates a new DirtySprite.
DirtySprite
  
dirty():void
Marks this sprite as "dirty" and in need of re-rendering.
DirtySprite
  
getBounds(targetCoordinateSpace:DisplayObject):Rectangle
If dirty, this sprite is re-rendered returning the bounds.
DirtySprite
  
getRect(targetCoordinateSpace:DisplayObject):Rectangle
If dirty, this sprite is re-rendered before returning the rect.
DirtySprite
  
hitTestObject(obj:DisplayObject):Boolean
If dirty, either sprite is re-rendered before hit-testing.
DirtySprite
  
hitTestPoint(x:Number, y:Number, shapeFlag:Boolean = false):Boolean
If dirty, this sprite is re-rendered before hit-testing.
DirtySprite
  
render():void
Draw this sprite's graphical content.
DirtySprite
  
renderDirty(evt:Event = null):void
[static] Frame render callback that renders all sprites on the dirty list.
DirtySprite
  
toString():String
DirtySprite
Public Constants
 ConstantDefined by
  ZERO : Point
[static] A constant for the point (0,0).
DirtySprite
Property detail
_angleproperty
protected var _angle:Number

The angle value of this sprite's position in polar co-ordinates. Polar coordinate values are assume a circle center given by the origin property.

angleproperty 
angle:Number  [read-write]

The angle value of this sprite's position in polar co-ordinates. Polar coordinate values are assume a circle center given by the origin property.

Implementation
    public function get angle():Number
    public function set angle(value:Number):void
heightproperty 
height:Number  [read-only]

If dirty, this sprite is re-rendered before returning the height.

Implementation
    public function get height():Number
_originproperty 
protected var _origin:Point

The origin point for polar coordinates.

originproperty 
origin:Point  [read-write]

The origin point for polar coordinates.

Implementation
    public function get origin():Point
    public function set origin(value:Point):void
_radiusproperty 
protected var _radius:Number

The radius value of this sprite's position in polar co-ordinates. Polar coordinate values are assume a circle center given by the origin property.

radiusproperty 
radius:Number  [read-write]

The radius value of this sprite's position in polar co-ordinates. Polar coordinate values are assume a circle center given by the origin property.

Implementation
    public function get radius():Number
    public function set radius(value:Number):void
widthproperty 
width:Number  [read-only]

If dirty, this sprite is re-rendered before returning the width.

Implementation
    public function get width():Number
xproperty 
x:Number  [write-only]

Implementation
    public function set x(value:Number):void
yproperty 
y:Number  [write-only]

Implementation
    public function set y(value:Number):void
Constructor detail
DirtySprite()constructor
public function DirtySprite()

Creates a new DirtySprite. Registers this Sprite to receive added-to-stage events.

Method detail
dirty()method
public final function dirty():void

Marks this sprite as "dirty" and in need of re-rendering. The next time that (a) a new frame is rendered, and (b) this Sprite is on the display list, the render method will automatically be called.

getBounds()method 
public override function getBounds(targetCoordinateSpace:DisplayObject):Rectangle

If dirty, this sprite is re-rendered returning the bounds.

Parameters
targetCoordinateSpace:DisplayObject

Returns
Rectangle
getRect()method 
public override function getRect(targetCoordinateSpace:DisplayObject):Rectangle

If dirty, this sprite is re-rendered before returning the rect.

Parameters
targetCoordinateSpace:DisplayObject

Returns
Rectangle
hitTestObject()method 
public override function hitTestObject(obj:DisplayObject):Boolean

If dirty, either sprite is re-rendered before hit-testing.

Parameters
obj:DisplayObject

Returns
Boolean
hitTestPoint()method 
public override function hitTestPoint(x:Number, y:Number, shapeFlag:Boolean = false):Boolean

If dirty, this sprite is re-rendered before hit-testing.

Parameters
x:Number
 
y:Number
 
shapeFlag:Boolean (default = false)

Returns
Boolean
render()method 
public function render():void

Draw this sprite's graphical content. Subclasses should override this method with custom drawing code.

renderDirty()method 
public static function renderDirty(evt:Event = null):void

Frame render callback that renders all sprites on the dirty list. Typically, this method is automatically triggered by stage RENDER events. It can also be manually invoked to redraw all dirty DirtySprites.

Parameters
evt:Event (default = null) — the event that triggered the rendering (can be null)
toString()method 
public override function toString():String

Returns
String
Constant detail
ZEROconstant
public static const ZERO:Point

A constant for the point (0,0).