Packagekrewfw.builtin_actor.system
Classpublic class KrewState
InheritanceKrewState Inheritance Object
Subclasses KrewSubState

State Object for KrewStateMachine.



Public Properties
 PropertyDefined By
  childStates : Vector.<KrewState>
[read-only]
KrewState
  guardFunc : Function
[read-only]
KrewState
  isListening : Boolean = false
KrewState
  krew : KrewTopUtil
[read-only]
KrewState
  listenList : Array
[read-only]
KrewState
  nextStateId : String
KrewState
  onBeginHandler : Function
[read-only]
KrewState
  onEndHandler : Function
[read-only]
KrewState
  onEnterHandler : Function
[read-only]
KrewState
  onExitHandler : Function
[read-only]
KrewState
  onUpdateHandler : Function
[read-only]
KrewState
  parentState : KrewState
KrewState
  sharedObj : KrewSharedObjects
[read-only]
KrewState
  stateId : String
[read-only]
KrewState
  stateMachine : KrewStateMachine
[write-only]
KrewState
Public Methods
 MethodDefined By
  
KrewState(stateDef:Object, funcOwner:Object = null, prefix:String)
Create state with Object key-values.
KrewState
  
addState(stateDef:*, funcOwner:Object = null, prefix:String):void
Add sub state.
KrewState
  
createActor(newActor:KrewActor, layerName:String = null):void
KrewState
  
delayed(timeout:Number, task:Function):void
KrewState
  
dispose():void
KrewState
  
dump():void
KrewState
  
dumpTree(level:int = 0):void
KrewState
  
eachChild(iterator:Function):void
Iterate state tree downward.
KrewState
  
eachParent(iterator:Function):void
Iterate state tree upward.
KrewState
  
hasChildren():Boolean
KrewState
  
hasParent():Boolean
KrewState
  
isChild(state:KrewState, nestCount:int = 0):Boolean
Return true if arg is my child state (grandchild is a child.)
KrewState
  
isEqual(state:KrewState):Boolean
Return true if arg is same state instance.
KrewState
  
makeState(stateDef:*, funcOwner:Object = null, prefix:String):KrewState
[static]
KrewState
  
onEvent(args:Object, event:String):void
イベントを受け取った際、 KrewStateMachine から呼ばれるハンドラ。 State は自分が listen しているイベントでなければ、親 state に委譲する。 自分が listen しているイベントだった場合でも、 guard に指定した function が false を返す間は、遷移を行わない。 guard を通過した際、hook が指定されていればそれに (state, eventArgs) を渡して呼ぶ。 その後、to に指定されていたステートへ遷移する
KrewState
  
proceed(state:KrewState = null):void
Go on the next state.
KrewState
  
sendMessage(eventType:String, eventArgs:Object = null):void
KrewState
Property Detail
childStatesproperty
childStates:Vector.<KrewState>  [read-only]


Implementation
    public function get childStates():Vector.<KrewState>
guardFuncproperty 
guardFunc:Function  [read-only]


Implementation
    public function get guardFunc():Function
isListeningproperty 
public var isListening:Boolean = false

krewproperty 
krew:KrewTopUtil  [read-only]


Implementation
    public function get krew():KrewTopUtil
listenListproperty 
listenList:Array  [read-only]


Implementation
    public function get listenList():Array
nextStateIdproperty 
nextStateId:String


Implementation
    public function get nextStateId():String
    public function set nextStateId(value:String):void
onBeginHandlerproperty 
onBeginHandler:Function  [read-only]


Implementation
    public function get onBeginHandler():Function
onEndHandlerproperty 
onEndHandler:Function  [read-only]


Implementation
    public function get onEndHandler():Function
onEnterHandlerproperty 
onEnterHandler:Function  [read-only]


Implementation
    public function get onEnterHandler():Function
onExitHandlerproperty 
onExitHandler:Function  [read-only]


Implementation
    public function get onExitHandler():Function
onUpdateHandlerproperty 
onUpdateHandler:Function  [read-only]


Implementation
    public function get onUpdateHandler():Function
parentStateproperty 
parentState:KrewState


Implementation
    public function get parentState():KrewState
    public function set parentState(value:KrewState):void
sharedObjproperty 
sharedObj:KrewSharedObjects  [read-only]


Implementation
    public function get sharedObj():KrewSharedObjects
stateIdproperty 
stateId:String  [read-only]


Implementation
    public function get stateId():String
stateMachineproperty 
stateMachine:KrewStateMachine  [write-only]


Implementation
    public function set stateMachine(value:KrewStateMachine):void
Constructor Detail
KrewState()Constructor
public function KrewState(stateDef:Object, funcOwner:Object = null, prefix:String)

Create state with Object key-values.

Parameters
stateDef:Object — Object including state options such as:
  • (Required) id : {String} - State name.
  • (Optional) next : {String} - Next state name. progress() will proceed state to the next. If omitted, next Array element is used as next state.
  • (Optional) enter : {Function(state:KrewState):void} - Called when state starts.
  • (Optional) update : {Function(state:KrewState, passedTime:Number):void} - Called during state or sub-state is selected.
  • (Optional) exit : {Function(state:KrewState):void} - Called when state ends.
  • (Optional) begin : {Function(state:KrewState):void} - Called when state or child state starts.
  • (Optional) end : {Function(state:KrewState):void} - Called when state or child state ends.
  • (Optional) guard : {Function(state:KrewState, event:String, args:Object):Boolean} - Called when event is triggered. Return false to prevent transition and bubbling event.
  • (Optional) listen : {Object or Array} - Ex.) [{event: "event_name", to:"target_state_name", hook:hookFunc}] - event で指定したイベントを受け取ったとき、to で指定した state に遷移する。 KrewStateMachine はイベントをまず現在の state に渡す。 state は自分で解決できない イベントだった場合は親 state に委譲していく
  • (Optional) children: {Array} - Sub state definition list.
listen で指定する hook には (state:KrewState, eventArgs:Object) が渡される。 hook は guard が false を返してイベントの遷移を止める場合には呼ばれない。 関数は直接 Function を指定するのではなく、関数名を文字列で指定することもできる。 その場合は第二引数にその関数を持つ Object を渡す必要がある。 prefix を指定すると、stateDef 内の id, next, to の先頭に prefix がついているものと見なされる。 内部だけで閉じている State を複数箇所で指定したい場合に用いる。
 
funcOwner:Object (default = null)
 
prefix:String
Method Detail
addState()method
public function addState(stateDef:*, funcOwner:Object = null, prefix:String):void

Add sub state.

Parameters

stateDef:* — KrewState のインスタンスか、State 定義情報を含む Object. Object のフォーマットについては KrewState 及び KrewStateMachine の コンストラクタのドキュメントを見よ。
 
funcOwner:Object (default = null)
 
prefix:String

createActor()method 
public function createActor(newActor:KrewActor, layerName:String = null):void

Parameters

newActor:KrewActor
 
layerName:String (default = null)

delayed()method 
public function delayed(timeout:Number, task:Function):void

Parameters

timeout:Number
 
task:Function

dispose()method 
public function dispose():void

dump()method 
public function dump():void

dumpTree()method 
public function dumpTree(level:int = 0):void

Parameters

level:int (default = 0)

eachChild()method 
public function eachChild(iterator:Function):void

Iterate state tree downward. Passes itself and children to iterator function.

Parameters

iterator:Function — function(state:KrewState):void

eachParent()method 
public function eachParent(iterator:Function):void

Iterate state tree upward. Passes itself and parents to iterator function.

Parameters

iterator:Function — function(state:KrewState):void

hasChildren()method 
public function hasChildren():Boolean

Returns
Boolean
hasParent()method 
public function hasParent():Boolean

Returns
Boolean
isChild()method 
public function isChild(state:KrewState, nestCount:int = 0):Boolean

Return true if arg is my child state (grandchild is a child.)

Parameters

state:KrewState
 
nestCount:int (default = 0)

Returns
Boolean
isEqual()method 
public function isEqual(state:KrewState):Boolean

Return true if arg is same state instance.

Parameters

state:KrewState

Returns
Boolean
makeState()method 
public static function makeState(stateDef:*, funcOwner:Object = null, prefix:String):KrewState

Parameters

stateDef:*
 
funcOwner:Object (default = null)
 
prefix:String

Returns
KrewState

See also

addState
onEvent()method 
public function onEvent(args:Object, event:String):void

イベントを受け取った際、 KrewStateMachine から呼ばれるハンドラ。 State は自分が listen しているイベントでなければ、親 state に委譲する。 自分が listen しているイベントだった場合でも、 guard に指定した function が false を返す間は、遷移を行わない。 guard を通過した際、hook が指定されていればそれに (state, eventArgs) を渡して呼ぶ。 その後、to に指定されていたステートへ遷移する

Parameters

args:Object
 
event:String

proceed()method 
public function proceed(state:KrewState = null):void

Go on the next state. [Hint] すぐに次のステートに遷移させたいような場合の定義には enter: proceed と書けばよい

Parameters

state:KrewState (default = null)

sendMessage()method 
public function sendMessage(eventType:String, eventArgs:Object = null):void

Parameters

eventType:String
 
eventArgs:Object (default = null)