Packagecom.whirled.contrib
Classpublic class ForkingToyState
InheritanceForkingToyState Inheritance flash.events.EventDispatcher

ForkingToyState manages the state of a toy such that more than one person can play with it simultaneously. This is best done for a puzzle or toy that will be manipulated by users through many possible states. This class allows a new entrant in the room to see that someone is manipulating the toy, but the new entrant does not need to grab a lock or wait for the toy to be free, they can start playing, and they will fork the state.



Protected Properties
 PropertyDefined by
  _ctrl : FurniControl
ForkingToyState
  _followKey : String
ForkingToyState
  _idleDelay : int
ForkingToyState
  _myKey : String
ForkingToyState
  _nonOwnersCanSave : Boolean
ForkingToyState
  _seqId : int
ForkingToyState
  _state : Object
ForkingToyState
  _timeout : Number = 0
ForkingToyState
Public Methods
 MethodDefined by
  
ForkingToyState(ctrl:FurniControl, nonOwnersCanSave:Boolean = true, idleOutTimer:int = 30, deleteCount:int = 7)
ToyState constructor.
ForkingToyState
  
getState():Object
Get the state, or null if it's not set.
ForkingToyState
  
Get the username of the player that set the current state, or null if unknown.
ForkingToyState
  
resetState():void
Completely reset the state.
ForkingToyState
  
setState(state:Object):void
Set the state.
ForkingToyState
Protected Methods
 MethodDefined by
  
findFollowState(deleteCount:int):void
ForkingToyState
  
handleMemoryChanged(event:ControlEvent):void
ForkingToyState
  
isSaving():Boolean
Are we saving the state changes that the local user is making? Can we? Should we?
ForkingToyState
  
setTimeout():void
ForkingToyState
Events
 EventSummaryDefined by
   The state updated event.ForkingToyState
Public Constants
 ConstantDefined by
  STATE_UPDATED : String = "stateUpdated"
[static] Event type constant.
ForkingToyState
Protected Constants
 ConstantDefined by
  RESET_KEY : String
[static]
ForkingToyState
  STATE_KEY : RegExp
[static]
ForkingToyState
  STATE_PREFIX : String = "_s#"
[static]
ForkingToyState
Property detail
_ctrlproperty
protected var _ctrl:FurniControl
_followKeyproperty 
protected var _followKey:String
_idleDelayproperty 
protected var _idleDelay:int
_myKeyproperty 
protected var _myKey:String
_nonOwnersCanSaveproperty 
protected var _nonOwnersCanSave:Boolean
_seqIdproperty 
protected var _seqId:int
_stateproperty 
protected var _state:Object
_timeoutproperty 
protected var _timeout:Number = 0
Constructor detail
ForkingToyState()constructor
public function ForkingToyState(ctrl:FurniControl, nonOwnersCanSave:Boolean = true, idleOutTimer:int = 30, deleteCount:int = 7)

ToyState constructor.

Parameters
ctrl:FurniControl — how many personalized states to save before some are deleted.
 
nonOwnersCanSave:Boolean (default = true)
 
idleOutTimer:int (default = 30)
 
deleteCount:int (default = 7)
Method detail
findFollowState()method
protected function findFollowState(deleteCount:int):voidParameters
deleteCount:int
getState()method 
public function getState():Object

Get the state, or null if it's not set.

Returns
Object
getUsernameOfState()method 
public function getUsernameOfState():String

Get the username of the player that set the current state, or null if unknown.

Returns
String
handleMemoryChanged()method 
protected function handleMemoryChanged(event:ControlEvent):voidParameters
event:ControlEvent
isSaving()method 
protected function isSaving():Boolean

Are we saving the state changes that the local user is making? Can we? Should we?

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

Completely reset the state.

setState()method 
public function setState(state:Object):void

Set the state. Ignores any states set by other clients.

Parameters
state:Object
setTimeout()method 
protected function setTimeout():void
Event detail
stateUpdatedevent 
Event object type: flash.events.Event

The state updated event. Dispatched when a new state is set by another client.

Constant detail
RESET_KEYconstant
protected static const RESET_KEY:String
STATE_KEYconstant 
protected static const STATE_KEY:RegExp
STATE_PREFIXconstant 
protected static const STATE_PREFIX:String = "_s#"
STATE_UPDATEDconstant 
public static const STATE_UPDATED:String = "stateUpdated"

Event type constant.