Skip to content

Instantly share code, notes, and snippets.

View neilmanuell's full-sized avatar

neil manuell neilmanuell

View GitHub Profile
@neilmanuell
neilmanuell / DataBinding.as
Created February 24, 2012 13:48
example of DataBinding using AS3signals
public class DataBinding
{
private var _data:IDataObject;
private var _renderer:IDataRenderer;
public function DataBinding(data:IDataObject, renderer:IDataRenderer)
{
_data = data;
_renderer = renderer;
_data.onChangeState.add( onDataChangeState );
@neilmanuell
neilmanuell / A) StateConfiguration.as
Last active September 27, 2015 13:37
AS3 API for TryHarderStateMachine
fsm
.configureState( StateNames.HAPPINESS )
.withEntryGuards( OnlyIfHappy, OnlyIfSmiling )
.withExitiGuards( OnlyIfAnxious )
.withTargets( StateNames.SADNESS, StateNames.ECSTACY );
@neilmanuell
neilmanuell / DefineProcesses.as
Created September 25, 2011 08:43
declaration of fluent Latchable Door FSM
// LATCH
// NB: if this Process is called in a State not declared as initiating a process,
// or as throwing an error, nothing will happen, but silently
// The CommandFlowMap will verify that each transition is valid, and all States have been declared.
commandFlowMap.configureProcess()
.onEvent( ProcessEventTypes.LATCH, ProcessEvent )
.ifCurrentState( StateNames.LOCKED )
.thenTransitionTo( StateNames.CLOSED, StateNames.OPENED, StateNames.LATCHED )
.ifCurrentState( StateNames.CLOSED )
.thenTransitionTo( StateNames.OPENED, StateNames.LATCHED )
@neilmanuell
neilmanuell / FSM.mxml
Created September 21, 2011 11:59
Possible syntax for pushing pre-declared instances onto an array property
<?xml version="1.0"?>
<fsm:FSMDeclaration
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:fsm="fsm.*"
initial="{s1}">
<fsm:states>
<fsm:State id="s1" transitions="{[t1,t2]}">
<fsm:State id="s2"/>
<fsm:State id="s3"/>
@neilmanuell
neilmanuell / FSM.mxml
Created September 21, 2011 11:51
pseudo-syntax for pushing a pre-declared instance onto a property
<?xml version="1.0"?>
<fsm:FSMDeclaration
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:fsm="fsm.*"
initial="{s1}">
<fsm:states>
<fsm:State id="s1">
<fsm:Transition ref="{t1}"/>
</fsm:State>
@neilmanuell
neilmanuell / Sequence.mxml
Created September 21, 2011 11:32
Example of two methods to add children to a Sequence
<s:Sequence id="s1"/>
<s:Move id="m1"/>
</s:Sequence>
<s:Sequence id="s2"/>
<s:children>
<s:Move id="m2"/>
</s:children>
</s:Sequence>
@neilmanuell
neilmanuell / FSM.mxml
Created September 21, 2011 11:13
Sketch for MXML building problem - this I understand.
<?xml version="1.0"?>
<fsm:FSMDeclaration
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:fsm="fsm.*"
initial="{s1}">
<fsm:State id="s1"/>
<fsm:State id="s2"/>
</fsm:FSMDeclaration>
<?xml version="1.0"?>
<fsm:FSMDeclaration
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:fsm="fsm.*"
initial="{s1}">
<fsm:State id="s1"/>
<fsm:State id="s2"/>
</fsm:FSMDeclaration>
@neilmanuell
neilmanuell / FSMInjector.as
Created August 25, 2011 20:18
example of how to retain classes for StateMachine util
public function FSMInjector( fsm:XML, commandMap:ICommandMap ){
this.fsm = fsm;
this.commandMap = commandMap;
}
public function addClass( value:Class ):void{
if( !validateIsCommand( value ) )
throw new Error ("not a command")
}
@neilmanuell
neilmanuell / MyStrictSignalWithDispatchValues.as
Created July 14, 2011 12:03
A strictly-typed signal with dispatchValue method wrapping the generic dispatch method
public class MyStrictSignal extends Signal{
public function MyStrictSignal():void{
super( String, int );
}
public function dispatchValues( name:String, index:int ):void{
dispatch( name, index );
}
}