Packagecom.whirled.contrib.card
Classpublic class NetArray

Encapsulates the access and schema information for maintaining a fixed size array of integers on a whirled game server using NetSubControl.



Public Properties
 PropertyDefined by
  length : int
[read-only] Access the fixed length of the array.
NetArray
Protected Properties
 PropertyDefined by
  _default : int
NetArray
  _gameCtrl : GameControl
NetArray
  _length : int
NetArray
  _name : String
NetArray
  net : NetSubControl
[read-only]
NetArray
Public Methods
 MethodDefined by
  
NetArray(gameCtrl:GameControl, name:String, length:int, defaultValue:int = 0)
Creates a new net array.
NetArray
  
forEach(fn:Function):void
Call the given function on each element of the array.
NetArray
  
getAt(idx:int):int
Gets the integer at the given index.
NetArray
  
increment(idx:int, amount:int):void
Adds an integer amount to the value at the given index.
NetArray
  
indexOf(value:int):int
Returns the index of the given value in the array, or -1 if not present.
NetArray
  
reset():void
Resets the contents of the array so that it has the given length and is filled with the default value.
NetArray
  
setAt(idx:int, value:int):void
Sets the integer at the given index.
NetArray
Property detail
_defaultproperty
protected var _default:int
_gameCtrlproperty 
protected var _gameCtrl:GameControl
_lengthproperty 
protected var _length:int
lengthproperty 
length:int  [read-only]

Access the fixed length of the array.

Implementation
    public function get length():int
_nameproperty 
protected var _name:String
netproperty 
net:NetSubControl  [read-only]Implementation
    protected function get net():NetSubControl
Constructor detail
NetArray()constructor
public function NetArray(gameCtrl:GameControl, name:String, length:int, defaultValue:int = 0)

Creates a new net array.

Parameters
gameCtrl:GameControl — the Top-level game controller for the game using this array
 
name:String — the name of the server-side array
 
length:int — the number of entries in the array
 
defaultValue:int (default = 0) — the optional value to use when populating or proxying an array
Method detail
forEach()method
public function forEach(fn:Function):void

Call the given function on each element of the array. If the resest method has not been called or has not completed its network round trip, does nothing.

Parameters
fn:Function
getAt()method 
public function getAt(idx:int):int

Gets the integer at the given index. If the array has not yet been created, returns the default value. This behavior is necessary since views of a game may need to be created prior to the completion of the round trip of the reset method call.

Parameters
idx:int

Returns
int
increment()method 
public function increment(idx:int, amount:int):void

Adds an integer amount to the value at the given index. If the reset method has not been called or has not completed its network round trip, an exception will be thrown (by NetSubControl).

Parameters
idx:int
 
amount:int
indexOf()method 
public function indexOf(value:int):int

Returns the index of the given value in the array, or -1 if not present.

Parameters
value:int

Returns
int
reset()method 
public function reset():void

Resets the contents of the array so that it has the given length and is filled with the default value. This should normally be called early on in a game by the controlling client.

setAt()method 
public function setAt(idx:int, value:int):void

Sets the integer at the given index. If the reset method has not been called or has not completed its network round trip, an exception will be thrown (by NetSubControl).

Parameters
idx:int
 
value:int