home *** CD-ROM | disk | FTP | other *** search
/ PCGUIA 2010 Software/Programs / PCGuia_programas.iso / Software / Utils / Livebrush / Install-LivebrushLite.air / livebrush.swf / scripts / com / livebrush / ui / GlobalSettingsController.as < prev    next >
Encoding:
Text File  |  2009-10-26  |  3.2 KB  |  88 lines

  1. package com.livebrush.ui
  2. {
  3.    import com.livebrush.data.FileManager;
  4.    import com.livebrush.data.GlobalSettings;
  5.    import flash.events.Event;
  6.    import flash.events.MouseEvent;
  7.    
  8.    public class GlobalSettingsController extends UIController
  9.    {
  10.       public function GlobalSettingsController(globalSettingsView:GlobalSettingsView)
  11.       {
  12.          super(globalSettingsView);
  13.          this.init();
  14.       }
  15.       
  16.       override protected function init() : void
  17.       {
  18.          this.uiAsset.addEventListener(Event.CHANGE,this.propsChangeEvent);
  19.          this.uiAsset.addEventListener(MouseEvent.CLICK,this.mouseEvent);
  20.          this.panelAsset.addEventListener(MouseEvent.MOUSE_DOWN,this.panelMouseEvent);
  21.          this.panelAsset.addEventListener(MouseEvent.MOUSE_UP,this.panelMouseEvent);
  22.       }
  23.       
  24.       private function get panelAsset() : Object
  25.       {
  26.          return this.globalSettingsView.panelAsset;
  27.       }
  28.       
  29.       private function mouseEvent(e:MouseEvent) : void
  30.       {
  31.          switch(e.target.name)
  32.          {
  33.             case "presetsBtn":
  34.                FileManager.getInstance().copyAppFiles();
  35.                break;
  36.             case "closeBtn":
  37.                ui.globalSettingsView = null;
  38.                ui.closeWindow(this.globalSettingsView);
  39.          }
  40.       }
  41.       
  42.       override public function die() : void
  43.       {
  44.          this.panelAsset.stopDrag();
  45.          this.uiAsset.removeEventListener(MouseEvent.CLICK,this.mouseEvent);
  46.          this.uiAsset.removeEventListener(Event.CHANGE,this.propsChangeEvent);
  47.          this.panelAsset.removeEventListener(MouseEvent.MOUSE_DOWN,this.panelMouseEvent);
  48.          this.panelAsset.removeEventListener(MouseEvent.MOUSE_UP,this.panelMouseEvent);
  49.       }
  50.       
  51.       private function panelMouseEvent(e:MouseEvent) : void
  52.       {
  53.          if(e.type == MouseEvent.CLICK && e.target.name.indexOf("help") > -1)
  54.          {
  55.             _loadHelp();
  56.          }
  57.          else if(e.type == MouseEvent.MOUSE_DOWN && e.target.name == "titleBtn" && this.globalSettingsView.enableDrag)
  58.          {
  59.             this.panelAsset.startDrag();
  60.          }
  61.          else if(e.type == MouseEvent.MOUSE_UP && e.target.name == "titleBtn" && this.globalSettingsView.enableDrag)
  62.          {
  63.             this.panelAsset.stopDrag();
  64.          }
  65.       }
  66.       
  67.       private function propsChangeEvent(e:Event) : void
  68.       {
  69.          GlobalSettings.CACHE_REALTIME = this.globalSettingsView.uiAsset.cacheVectors.selected;
  70.          GlobalSettings.CACHE_DECOS = this.globalSettingsView.uiAsset.cacheDecos.selected;
  71.          GlobalSettings.CHECK_FOR_UPDATES = this.globalSettingsView.uiAsset.checkForUpdates.selected;
  72.          GlobalSettings.SHOW_BUSY_WARNINGS = this.globalSettingsView.uiAsset.showBusyWarnings.selected;
  73.          GlobalSettings.CACHE_DELAY = Math.min(4000,Math.max(50,Number(this.globalSettingsView.uiAsset.cacheDelay.text) * 1000));
  74.       }
  75.       
  76.       private function get globalSettingsView() : GlobalSettingsView
  77.       {
  78.          return GlobalSettingsView(view);
  79.       }
  80.       
  81.       private function get uiAsset() : SettingsUI
  82.       {
  83.          return this.globalSettingsView.uiAsset;
  84.       }
  85.    }
  86. }
  87.  
  88.