Skip to content

Instantly share code, notes, and snippets.

View neilmanuell's full-sized avatar

neil manuell neilmanuell

View GitHub Profile
@neilmanuell
neilmanuell / PlayingCard.as
Created March 24, 2011 12:20
example of enumberation type
package {
public class PlayingCard {
public static const SIX_OF_CLUBS:PlayingCard = new PlayingCard( "clubs", 6);
public static const JACK_OF_HEARTS:PlayingCard = new PlayingCard( "hearts", 11);
private var _index:int;
private var _suit:String;
public function PlayingCard(suit:String, index:int) {
@neilmanuell
neilmanuell / newStateDeclarationForGuardedCommands.xml
Created March 17, 2011 12:58
New xml declaration incorporating command guards for robotLegs/signal flavoured (as3)statemachine
<!-- Root declaration unchanged -->
<fsm initial="starting">
<!--
State declaration with unique name.
The phase signal attribute declarations have been migrated to child elements.
-->
<state name="starting">
<!-- Declaration for enteringGuard signal -->
<enteringGuard>
<!--
@neilmanuell
neilmanuell / custom_compiler_config.xml
Created March 13, 2011 09:24
example custom compiler confix xml for GuardedCommandMap
<flex-config xmlns="http://www.adobe.com/2006/flex-config">
<target-player>9.0.124</target-player>
<compiler>
<debug>true</debug>
<source-path>
<path-element>src</path-element>
</source-path>
<library-path append="true">
</library-path>
<external-library-path>
@neilmanuell
neilmanuell / LockedStateTransitionPhases.as
Created March 6, 2011 10:40
Pseudocode examples of Locked State transition phases
////////////////////////////////////////////
// exiting guard
if( !lock.isKeyValid( user ) ){
fsm.cancel( Reasons.KEY_INVALID );
}
////////////////////////////////////////////
////////////////////////////////////////////
// cancelled
if( reason == Reasons.KEY_INVALID ){
@neilmanuell
neilmanuell / LockDoorActionCall.as
Created February 25, 2011 12:40
Example of executing the Close MacroAction
[Inject(name="lockDoor")]
public var lockDoor:IActionable;
public function onClick( event:MouseEvent ):void{
lockDoor.action()
}
@neilmanuell
neilmanuell / InjectFSMProperties.as
Created February 25, 2011 11:40
Inject FSMProperties as IFSMProperties (Robotlegs)
injector.mapClass( IFSMProperties, FSMProperties )
@neilmanuell
neilmanuell / LockDoor.as
Created February 25, 2011 11:16
Example implementation of a MacroAction
public class LockDoor extends BaseMacroAction
{
override protected function initiateMacroAction( payload:Object ):void
{
sendAction( ActionNames.CLOSE);
sendAction( ActionNames.LOCK, payload );
}
}
@neilmanuell
neilmanuell / IActionable.as
Created February 25, 2011 11:13
Contract for BaseMacroAction
public interface IActionable
{
function action( payload:Object = null ):void
}
@neilmanuell
neilmanuell / BaseMacroAction.as
Created February 25, 2011 11:10
Base class for sending multiple synchronous actions
public class BaseMacroAction implements IActionable
{
private var _fsmController:IFSMController;
[Inject]
public function set fsmController( value:IFSMController ):void
{
_fsmController = value;
}
@neilmanuell
neilmanuell / FSMProperties.as
Created February 25, 2011 11:06
Limits the access of the IFSMController to its properties
import org.osflash.statemachine.core.IFSMController;
public class FSMProperties implements IFSMProperties
{
private var _fsmController:IFSMController;
[Inject]
public function set fsmController( value:IFSMController ):void
{