Posted By

wintondeshong on 05/02/08


Tagged

class textmate Mediator actionscript3 PureMVC


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

n00ge


PureMVC StageMediator Class Template


 / Published in: Other
 

  1. /**
  2. * Base PureMVC Project
  3. */
  4. package view
  5. {
  6. import flash.display.Stage;
  7. import flash.events.MouseEvent;
  8. import org.puremvc.as3.interfaces.*;
  9. import org.puremvc.as3.patterns.mediator.Mediator;
  10.  
  11. import ApplicationFacade;
  12.  
  13. /**
  14. * A Mediator for interacting with the Stage.
  15. */
  16. public class StageMediator extends Mediator implements IMediator
  17. {
  18. // Cannonical name of the Mediator
  19. public static const NAME:String = "StageMediator";
  20.  
  21. public function StageMediator( viewComponent:Object )
  22. {
  23. /**
  24. * pass the viewComponent to the superclass where
  25. * it will be stored in the inherited viewComponent property
  26. */
  27. super( NAME, viewComponent );
  28. }
  29.  
  30. /**
  31. * StageMediator lists the INITIALIZE_SITE notification as an
  32. * event of interest. You may list as many notification
  33. * interests as needed.
  34. */
  35. override public function listNotificationInterests():Array
  36. {
  37. return [
  38. ApplicationFacade.INITIALIZE_SITE
  39. ];
  40. }
  41.  
  42. /**
  43. * Called by the framework when a notification is sent that
  44. * this mediator expressed an interest in.
  45. */
  46. override public function handleNotification( note:INotification ):void
  47. {
  48. switch ( note.getName() )
  49. {
  50. /**
  51. * If the notification sent has a name matching
  52. * ApplicationFacade.INITIALIZE_SITE then this code block will execute
  53. */
  54. case ApplicationFacade.INITIALIZE_SITE:
  55. initializeSite();
  56. break;
  57. }
  58. }
  59.  
  60. /**
  61. * Called to handle the INITIALIZE_SITE notification.
  62. * Creates SiteMediator, NavMediator, BodyMediator to provide
  63. * PureMVC functionality to the varies view components of the application.
  64. */
  65. private function initializeSite():void
  66. {
  67.  
  68. }
  69.  
  70. /**
  71. * Retrieves the viewComponent and casting it to type Stage
  72. */
  73. protected function get stage():Stage
  74. {
  75. return viewComponent as Stage;
  76. }
  77. }
  78. }

Report this snippet  

You need to login to post a comment.