Packagecom.whirled.contrib.card.graphics
Classpublic class CardArraySprite
InheritanceCardArraySprite Inheritance flash.display.Sprite
SubclassesHandSprite, TrickSprite

Superclass to display of an array of cards. Delegates layout and some animation to subclasses.



Public Properties
 PropertyDefined by
  factory : CardSpriteFactory
[read-only] Access the factory for card creation and layout.
CardArraySprite
Protected Properties
 PropertyDefined by
  _animations : Array
CardArraySprite
  _cards : Array
CardArraySprite
  _factory : CardSpriteFactory
CardArraySprite
  _target : CardArray
CardArraySprite
Public Methods
 MethodDefined by
  
CardArraySprite(target:CardArray, factory:CardSpriteFactory, doPositioning:Boolean = true)
Create a new sprite for a CardArray.
CardArraySprite
Protected Methods
 MethodDefined by
  
Animates the addition of the card.
CardArraySprite
  
Animates the removal of a card.
CardArraySprite
  
When the card array changes, update our child sprites and re-layout.
CardArraySprite
  
getStaticCardPosition(i:int, pos:Point):void
Get the x, y position of a card in the array.
CardArraySprite
  
Positions all cards (that are not currently animating).
CardArraySprite
  
refresh():void
Update our card sprites with the contents of the target card array.
CardArraySprite
Property detail
_animationsproperty
protected var _animations:Array
_cardsproperty 
protected var _cards:Array
_factoryproperty 
protected var _factory:CardSpriteFactory
factoryproperty 
factory:CardSpriteFactory  [read-only]

Access the factory for card creation and layout.

Implementation
    public function get factory():CardSpriteFactory
_targetproperty 
protected var _target:CardArray
Constructor detail
CardArraySprite()constructor
public function CardArraySprite(target:CardArray, factory:CardSpriteFactory, doPositioning:Boolean = true)

Create a new sprite for a CardArray. The sprite will always listen for all changes on the array events and unregister when removed from the display list. Re-adding to the display list is not supported.

Parameters
target:CardArray — the CardArray to listen to for changes to the sprite
 
factory:CardSpriteFactory — the embedded deck object to use when creating CardSprite instances
 
doPositioning:Boolean (default = true) — specify whether to call positionCards
Method detail
animateAddition()method
protected function animateAddition(card:CardSprite):void

Animates the addition of the card. Default does nothing. Subclasses should set the starting position of the card and use slide to move it into its static position.

Parameters
card:CardSprite
animateRemoval()method 
protected function animateRemoval(card:CardSprite):void

Animates the removal of a card. The _cards array will be taken care of, this function must only guarantee that removeChild is called later. By default, just calls removeChild immediately.

Parameters
card:CardSprite
cardArrayListener()method 
protected function cardArrayListener(event:CardArrayEvent):void

When the card array changes, update our child sprites and re-layout.

Parameters
event:CardArrayEvent
getStaticCardPosition()method 
protected function getStaticCardPosition(i:int, pos:Point):void

Get the x, y position of a card in the array. The base implmentation just lays out the cards in a row using some hard-wired constants for width and height. Subclasses should override and use more specific values.

Parameters
i:int
 
pos:Point
positionCards()method 
protected function positionCards():void

Positions all cards (that are not currently animating).

refresh()method 
protected function refresh():void

Update our card sprites with the contents of the target card array.