Posted By

derrekwayne on 08/19/10


Tagged

actionscript model mcv


Versions (?)

Neonsunburst Model Class


 / Published in: ActionScript 3
 

URL: neonsunburst.com

The singleton model extends EventDispatcher and fires events when it is updated by the controller.

  1. package com.neonsunburst {
  2.  
  3. import flash.events.*;
  4.  
  5. public class Model extends EventDispatcher {
  6.  
  7. public static var totalPages:int;
  8. public static var currentPage:int;
  9. public static var previousPage:int;
  10.  
  11. function Model() {
  12. totalPages = 3;
  13. currentPage = 1;
  14. }
  15. function setCurrentPage(p:int) : void {
  16. previousPage = currentPage;
  17. currentPage = p;
  18. trace (this + " currentPage is " + currentPage);
  19. trace (this + " previousPage is " + previousPage);
  20. dispatchEvent(new Event(Event.CHANGE));
  21. }
  22. function getCurrentPage() : int {
  23. return currentPage;
  24. }
  25. function getPreviousPage() : int {
  26. return previousPage;
  27. }
  28. function getTotalPages() : int {
  29. return totalPages;
  30. }
  31.  
  32.  
  33. }
  34. }

Report this snippet  

You need to login to post a comment.