home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Diversos / Beez.swf / scripts / game / view / AppMediator.as next >
Encoding:
Text File  |  2008-09-03  |  2.8 KB  |  102 lines

  1. package game.view
  2. {
  3.    import flash.display.Sprite;
  4.    import flash.events.MouseEvent;
  5.    import flash.media.Sound;
  6.    import flash.media.SoundChannel;
  7.    import flash.net.URLRequest;
  8.    import flash.net.navigateToURL;
  9.    import game.model.AppProxy;
  10.    import game.model.GameAssets;
  11.    import game.view.components.AppView;
  12.    import org.puremvc.as3.interfaces.IMediator;
  13.    import org.puremvc.as3.interfaces.INotification;
  14.    import org.puremvc.as3.patterns.mediator.Mediator;
  15.    
  16.    public class AppMediator extends Mediator implements IMediator
  17.    {
  18.       
  19.       public static const NAME:String = "AppMediator";
  20.        
  21.       
  22.       private var _view:AppView;
  23.       
  24.       private var music:Sound;
  25.       
  26.       private var sndChannel:SoundChannel;
  27.       
  28.       public function AppMediator(viewComponent:AppView)
  29.       {
  30.          super(NAME,viewComponent);
  31.          init();
  32.       }
  33.       
  34.       override public function listNotificationInterests() : Array
  35.       {
  36.          return [AppProxy.INSTRUCTIONS_SHOW,AppProxy.INSTRUCTIONS_HIDE,AppProxy.MUSIC_TOGGLE];
  37.       }
  38.       
  39.       override public function handleNotification(note:INotification) : void
  40.       {
  41.          switch(note.getName())
  42.          {
  43.             case AppProxy.INSTRUCTIONS_SHOW:
  44.             case AppProxy.INSTRUCTIONS_HIDE:
  45.                break;
  46.             case AppProxy.MUSIC_TOGGLE:
  47.                musicToggle();
  48.          }
  49.       }
  50.       
  51.       public function startMusic() : void
  52.       {
  53.          var appProxy:AppProxy = facade.retrieveProxy(AppProxy.NAME) as AppProxy;
  54.          sndChannel = music.play(0,100000,appProxy.musicTransform);
  55.       }
  56.       
  57.       public function getViewContainer() : Sprite
  58.       {
  59.          return _view.container;
  60.       }
  61.       
  62.       public function getPopupContainer() : Sprite
  63.       {
  64.          return _view.popupContainer;
  65.       }
  66.       
  67.       private function logoClickHandler(e:MouseEvent) : void
  68.       {
  69.          navigateToURL(new URLRequest("http://rusfund.ru"),"_blank");
  70.       }
  71.       
  72.       private function init() : void
  73.       {
  74.          _view = getViewComponent() as AppView;
  75.          _view.tabChildren = false;
  76.          initSound();
  77.       }
  78.       
  79.       public function getScoresContainer() : Sprite
  80.       {
  81.          return _view.scoresContainer;
  82.       }
  83.       
  84.       public function stopMusic() : void
  85.       {
  86.          sndChannel.stop();
  87.       }
  88.       
  89.       private function musicToggle() : void
  90.       {
  91.          var appProxy:AppProxy = facade.retrieveProxy(AppProxy.NAME) as AppProxy;
  92.          sndChannel.soundTransform = appProxy.musicTransform;
  93.       }
  94.       
  95.       private function initSound() : void
  96.       {
  97.          var MusicClass:Class = GameAssets.getInstance().getAssetClass("SndMusic");
  98.          music = new MusicClass();
  99.       }
  100.    }
  101. }
  102.