/src/com/yodana/simplemvc/as3/core/Controller.as

https://github.com/yodsan/SimpleMVC
ActionScript | 120 lines | 73 code | 32 blank | 15 comment | 0 complexity | 5431c4a9a925e6f27aff6089c13d8632 MD5 | raw file
  1. package com.yodana.simplemvc.as3.core
  2. {
  3. import com.yodana.simplemvc.as3.interfaces.IBaseController;
  4. import com.yodana.simplemvc.as3.interfaces.IModel;
  5. import com.yodana.simplemvc.as3.interfaces.IView;
  6. import flash.display.Sprite;
  7. /**
  8. * @author Yodana Thorsdal Santiago
  9. */
  10. public class Controller extends Sprite implements IBaseController
  11. {
  12. private var _globalNotifier: Notifier;
  13. private var _notifier: Notifier;
  14. private var _model: IModel;
  15. private var _view: IView;
  16. /**************************************************************************************************************
  17. * Constructor
  18. **************************************************************************************************************/
  19. public function Controller()
  20. {
  21. }
  22. /**************************************************************************************************************
  23. * Public functions
  24. **************************************************************************************************************/
  25. public function registerModel( model: IModel ): void
  26. {
  27. this.model = model;
  28. }
  29. public function registerView( view: IView ): void
  30. {
  31. this.view = view;
  32. }
  33. public function registerNotifier( notifier: Notifier ): void
  34. {
  35. this.notifier = notifier;
  36. }
  37. public function registerGlobalNotifier( notifier: Notifier ): void
  38. {
  39. this.globalNotifier = notifier;
  40. }
  41. public function destroy(): void
  42. {
  43. erase();
  44. }
  45. /**************************************************************************************************************
  46. * Private functions
  47. **************************************************************************************************************/
  48. private function erase(): void
  49. {
  50. notifier = null;
  51. }
  52. /**************************************************************************************************************
  53. * Getters/Setters
  54. **************************************************************************************************************/
  55. protected function get notifier(): Notifier
  56. {
  57. return _notifier;
  58. }
  59. protected function set notifier(notifier: Notifier): void
  60. {
  61. _notifier = notifier;
  62. }
  63. protected function get model(): IModel
  64. {
  65. return _model;
  66. }
  67. protected function set model(model: IModel): void
  68. {
  69. _model = model;
  70. }
  71. protected function get view(): IView
  72. {
  73. return _view;
  74. }
  75. protected function set view(view: IView): void
  76. {
  77. _view = view;
  78. }
  79. protected function get globalNotifier(): Notifier
  80. {
  81. return _globalNotifier;
  82. }
  83. protected function set globalNotifier(globalNotifier: Notifier): void
  84. {
  85. _globalNotifier = globalNotifier;
  86. }
  87. }
  88. }