Packagecom.whirled.contrib.card.graphics
Classpublic class HandSprite
InheritanceHandSprite Inheritance CardArraySprite Inheritance flash.display.Sprite

Display for a hand of cards



Public Properties
 PropertyDefined by
 Inheritedfactory : CardSpriteFactory
Access the factory for card creation and layout.
CardArraySprite
Protected Properties
 PropertyDefined by
  _added : Array
HandSprite
 Inherited_animations : Array
CardArraySprite
 Inherited_cards : Array
CardArraySprite
 Inherited_factory : CardSpriteFactory
CardArraySprite
  _floater : CardSprite
HandSprite
  _hand : Hand
HandSprite
  _removedCards : Array
HandSprite
  _selectCount : int
HandSprite
  _selected : Array
HandSprite
 Inherited_target : CardArray
CardArraySprite
  _userPreselect : Boolean
HandSprite
Public Methods
 MethodDefined by
  
Create a new hand sprite.
HandSprite
  
Grab the card sprites that were recently removed from the hand.
HandSprite
Protected Methods
 MethodDefined by
  
HandSprite
  
HandSprite
  
HandSprite
  
clickListener(event:MouseEvent):void
HandSprite
  
deselect(card:CardSprite):void
HandSprite
  
disable():void
Disable clicking on all cards.
HandSprite
  
HandSprite
  
enable(subset:CardArray = null):void
Enable clicking on specific cards.
HandSprite
  
findCard(event:MouseEvent):CardSprite
HandSprite
  
HandSprite
  
HandSprite
  
floatCard(card:CardSprite):void
Slide a card vertically to indicate that clicking it will play it.
HandSprite
 Inherited
getStaticCardPosition(i:int, pos:Point):void
Get the x, y position of a card in the array.
CardArraySprite
  
handListener(event:HandEvent):void
HandSprite
  
isSelected(card:CardSprite):Boolean
HandSprite
 Inherited
Positions all cards (that are not currently animating).
CardArraySprite
 Inherited
refresh():void
Update our card sprites with the contents of the target card array.
CardArraySprite
  
select(card:CardSprite, userAction:Boolean):void
HandSprite
  
unfloatCard():void
Slide the currently floating card back into its usual location.
HandSprite
  
updateFloater(event:MouseEvent):void
HandSprite
  
verticalTween(card:CardSprite, offset:int):void
HandSprite
Protected Constants
 ConstantDefined by
  FLOAT_DURATION : Number = .2
[static]
HandSprite
  FLOAT_HEIGHT : Number = 10
[static]
HandSprite
  MAX_HAND_SIZE : int = 15
[static]
HandSprite
  REMOVAL_DURATION : Number = .75
[static]
HandSprite
  SELECT_HEIGHT : Number = 20
[static]
HandSprite
  SQUEEZE_DURATION : Number = .75
[static]
HandSprite
Property detail
_addedproperty
protected var _added:Array
_floaterproperty 
protected var _floater:CardSprite
_handproperty 
protected var _hand:Hand
_removedCardsproperty 
protected var _removedCards:Array
_selectCountproperty 
protected var _selectCount:int
_selectedproperty 
protected var _selected:Array
_userPreselectproperty 
protected var _userPreselect:Boolean
Constructor detail
HandSprite()constructor
public function HandSprite(hand:Hand, factory:CardSpriteFactory)

Create a new hand sprite.

Parameters
hand:Hand — the card array this sprite represents
 
factory:CardSpriteFactory — the embedded deck object to use when creating instances of CardSprite
Method detail
animateAddition()method
protected override function animateAddition(card:CardSprite):voidParameters
card:CardSprite
animateRemoval()method 
protected override function animateRemoval(card:CardSprite):voidParameters
card:CardSprite
cardArrayListener()method 
protected override function cardArrayListener(event:CardArrayEvent):voidParameters
event:CardArrayEvent
clickListener()method 
protected function clickListener(event:MouseEvent):voidParameters
event:MouseEvent
deselect()method 
protected function deselect(card:CardSprite):voidParameters
card:CardSprite
disable()method 
protected function disable():void

Disable clicking on all cards.

dispatchSelection()method 
protected function dispatchSelection():void
enable()method 
protected function enable(subset:CardArray = null):void

Enable clicking on specific cards.

Parameters
subset:CardArray (default = null) — the cards to enable, or all if null (default)

Throws
— is the resulting set of enabled cards is empty since otherwise the game will be waiting forever.
finalizeRemovals()method 
public function finalizeRemovals():Array

Grab the card sprites that were recently removed from the hand. After each card is removed, its sprite is animated towards a central location and added to an array. It is expected that the TrickSprite or some other card game view object will call this function to take control of the removed cards. Card sprites accessed from this function will be free of positional tweens and removed from the parent container (this).

Returns
Array — an Array of CardSprite objects.
findCard()method 
protected function findCard(event:MouseEvent):CardSpriteParameters
event:MouseEvent

Returns
CardSprite
findCardByLocalXY()method 
protected function findCardByLocalXY(x:int, y:int):CardSpriteParameters
x:int
 
y:int

Returns
CardSprite
findCardByX()method 
protected function findCardByX(xpos:int):CardSpriteParameters
xpos:int

Returns
CardSprite
floatCard()method 
protected function floatCard(card:CardSprite):void

Slide a card vertically to indicate that clicking it will play it.

Parameters
card:CardSprite — the mouse position in the card's coordinates.
handListener()method 
protected function handListener(event:HandEvent):voidParameters
event:HandEvent
isSelected()method 
protected function isSelected(card:CardSprite):BooleanParameters
card:CardSprite

Returns
Boolean
select()method 
protected function select(card:CardSprite, userAction:Boolean):voidParameters
card:CardSprite
 
userAction:Boolean
unfloatCard()method 
protected function unfloatCard():void

Slide the currently floating card back into its usual location.

updateFloater()method 
protected function updateFloater(event:MouseEvent):voidParameters
event:MouseEvent
verticalTween()method 
protected function verticalTween(card:CardSprite, offset:int):voidParameters
card:CardSprite
 
offset:int
Constant detail
FLOAT_DURATIONconstant
protected static const FLOAT_DURATION:Number = .2
FLOAT_HEIGHTconstant 
protected static const FLOAT_HEIGHT:Number = 10
MAX_HAND_SIZEconstant 
protected static const MAX_HAND_SIZE:int = 15
REMOVAL_DURATIONconstant 
protected static const REMOVAL_DURATION:Number = .75
SELECT_HEIGHTconstant 
protected static const SELECT_HEIGHT:Number = 20
SQUEEZE_DURATIONconstant 
protected static const SQUEEZE_DURATION:Number = .75