Neonsunburst Controller Class


/ Published in: ActionScript 3
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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. }

URL: neonsunburst.com

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.