/src/05_Prius_PuzzleExpandable/Production/lib/src/cc/core/AbstractApplication.as

https://github.com/socialvibe/engagements_FLAs
ActionScript | 141 lines | 55 code | 20 blank | 66 comment | 1 complexity | 77ab336fd6b3611765f8dd29e49caf67 MD5 | raw file
  1. package cc.core
  2. {
  3. import flash.display.Sprite;
  4. import cc.utils.StringUtils;
  5. import cc.core.StateManager;
  6. import cc.core.ViewManager;
  7. import cc.core.ControlManager;
  8. import flash.events.Event;
  9. /**
  10. * Abstract Application based on
  11. * WesterFreight's design pattern from 2008.
  12. *
  13. * @langversion ActionScript 3
  14. * @playerversion Flash 10.0.0
  15. *
  16. * @author Carl Calderon (carl.calderon@gmail.com)
  17. * @since 14.01.2011
  18. */
  19. public class AbstractApplication extends Sprite
  20. {
  21. /**
  22. * Define if history should be used.
  23. * Default 'true'
  24. */
  25. public var useHistory :Boolean = true;
  26. /**
  27. * @private
  28. * Proxy holder.
  29. */
  30. private var _proxy :HashMap;
  31. /**
  32. * @private
  33. * Command holder.
  34. */
  35. private var _control :ControlManager;
  36. /**
  37. * @private
  38. * View holder.
  39. */
  40. private var _view :ViewManager;
  41. /**
  42. * @private
  43. * State holder.
  44. */
  45. private var _state :StateManager;
  46. /**
  47. * @private
  48. * History holder.
  49. */
  50. private var _history :History;
  51. ////////////////////////////////////////////////////////
  52. //
  53. // Constructor
  54. //
  55. ////////////////////////////////////////////////////////
  56. /**
  57. * @constructor
  58. * Application entry point.
  59. */
  60. public function AbstractApplication()
  61. {
  62. super();
  63. _proxy = new HashMap();
  64. _state = new StateManager();
  65. _control = new ControlManager(this);
  66. _view = new ViewManager(this);
  67. if(useHistory)
  68. {
  69. _history = new History(_state);
  70. _state.history = _history;
  71. }
  72. }
  73. ////////////////////////////////////////////////////////
  74. //
  75. // Getter Setters
  76. //
  77. ////////////////////////////////////////////////////////
  78. /**
  79. * Proxy holder
  80. */
  81. public function get proxy():HashMap
  82. {
  83. return _proxy;
  84. }
  85. /**
  86. * Command holder
  87. */
  88. public function get control():ControlManager
  89. {
  90. return _control;
  91. }
  92. /**
  93. * State holder
  94. */
  95. public function get state():StateManager
  96. {
  97. return _state;
  98. }
  99. /**
  100. * View holder
  101. */
  102. public function get view():ViewManager
  103. {
  104. return _view;
  105. }
  106. /**
  107. * History holder.
  108. */
  109. public function get history():History
  110. {
  111. return _history;
  112. }
  113. /**
  114. * @inheritDoc
  115. */
  116. override public function toString():String
  117. {
  118. return StringUtils.formatToString(this,'control','state','view');
  119. }
  120. }
  121. }