Posted By

derrekwayne on 08/19/10


Tagged

actionscript controller mcv


Versions (?)

Neonsunburst Controller Class


 / Published in: ActionScript 3
 

URL: neonsunburst.com

The Controller class handles user gestures through navigation logic and updates the Model.

  1. package com.neonsunburst {
  2.  
  3. import flash.events.*;
  4.  
  5. public class Controller {
  6.  
  7. var model:Model;
  8.  
  9. public function Controller (aModel:Model)
  10. {
  11. model= aModel;
  12. model.addEventListener(Event.CHANGE, update);
  13. if (model.hasEventListener(Event.CHANGE)) { trace ("Event.CHANGE regestered in controller"); };
  14.  
  15. }
  16.  
  17. public function forward() : void { // VIEW GESTURE IN
  18. if (model.getCurrentPage() == model.getTotalPages()) { model.setCurrentPage(1); }
  19. else { model.setCurrentPage(model.getCurrentPage() + 1 ); }
  20. }
  21.  
  22. public function backward() : void { // VIEW GESTURE IN
  23. if (model.getCurrentPage() == 1) { model.setCurrentPage( model.getTotalPages() ); }
  24. else { model.setCurrentPage( model.getCurrentPage() - 1 ); }
  25. }
  26. }
  27. }

Report this snippet  

You need to login to post a comment.