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 var _ctrl:FurniControl
protected var _followKey:String
protected var _idleDelay:int
protected var _myKey:String
protected var _nonOwnersCanSave:Boolean
protected var _seqId:int
protected var _state:Object
protected var _timeout:Number = 0
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) |
protected function findFollowState(deleteCount:int):voidParameters
public function getState():Object
Get the state, or null if it's not set.
Returns
public function getUsernameOfState():String
Get the username of the player that set the current state, or null if unknown.
Returns
protected function handleMemoryChanged(event:ControlEvent):voidParameters
protected function isSaving():Boolean
Are we saving the state changes that the local user is making? Can we?
Should we?
Returns
public function resetState():void
Completely reset the state.
public function setState(state:Object):void
Set the state. Ignores any states set by other clients.
Parameters
protected function setTimeout():void
Event object type: flash.events.Event
The state updated event. Dispatched when a new state is set by another client.
protected static const RESET_KEY:String
protected static const STATE_KEY:RegExp
protected static const STATE_PREFIX:String = "_s#"
public static const STATE_UPDATED:String = "stateUpdated" Event type constant.