-
-
Save brian428/721058 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BaseCompositeChain extends AbstractChain implements IChain | |
{ | |
public function BaseCompositeChain( mode:String = ChainType.SEQUENCE, stopOnError:Boolean = true ) | |
{ | |
super( mode, stopOnError ); | |
} | |
public function doProceed():void | |
{ | |
if( currentStep is IAutonomousChainStep ) | |
IAutonomousChainStep( currentStep ).doProceed(); | |
else if( currentStep is IChain ) | |
IChain( currentStep ).start(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function doEventChain() : void | |
{ | |
var eventChain : EventChain = new EventChain( dispatcher ); | |
eventChain.addEventListener( ChainEvent.CHAIN_COMPLETE, handleChainComplete, false, 0, true ); | |
eventChain.addStep( new EventChainStep( new UserEvent( UserEvent.USER_SCREEN_ACTIVE ) ) ); | |
eventChain.addStep( new EventChainStep( new UserEvent( UserEvent.USER_PROCESSING_COMPLETE ) ) ); | |
eventChain.start(); | |
} | |
[EventHandler( event="UserEvent.USER_SCREEN_ACTIVE" )] | |
public function logUserScreenActive() : void | |
{ | |
// perform logic or dispatch events when the user screen is active | |
} | |
[EventHandler( event="UserEvent.USER_PROCESSING_COMPLETE" )] | |
public function logUserProcessingComplete() : void | |
{ | |
// perform logic or dispatch events when the processing finishes | |
} | |
public function handleChainComplete( event : Event ) : void | |
{ | |
// perform logic or dispatch events when the chain is complete | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface IAutonomousChainStep extends IChainStep | |
{ | |
function doProceed():void; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface IChain extends IEventDispatcher | |
{ | |
function get position():int; | |
function set position( value:int ):void; | |
function get isComplete():Boolean; | |
function get stopOnError():Boolean; | |
function set stopOnError( value:Boolean ):void; | |
function hasNext():Boolean; | |
function stepComplete():void; | |
function stepError():void; | |
function addStep( step:IChainStep ):IChain; | |
function start():void; | |
function doProceed():void; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface IChainStep | |
{ | |
function get chain():IChain; | |
function set chain( value:IChain ):void; | |
function get isComplete():Boolean; | |
function complete():void; | |
function error():void; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment