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 / DialogView.as < prev    next >
Encoding:
Text File  |  2009-10-26  |  5.3 KB  |  165 lines

  1. package com.livebrush.ui
  2. {
  3.    import com.livebrush.events.UpdateEvent;
  4.    import com.livebrush.utils.Update;
  5.    import flash.display.MovieClip;
  6.    import flash.display.Sprite;
  7.    import flash.text.TextField;
  8.    
  9.    public class DialogView extends UIView
  10.    {
  11.       public var panelAsset:DialogAsset;
  12.       
  13.       public var enableDrag:Boolean = true;
  14.       
  15.       public var uiAsset:Sprite;
  16.       
  17.       public function DialogView(dialogModel:Dialog)
  18.       {
  19.          super(dialogModel);
  20.          init();
  21.       }
  22.       
  23.       override public function die() : void
  24.       {
  25.          this.dialogController.die();
  26.          UI.DIALOG_HOLDER.removeChild(this.panelAsset);
  27.          this.panelAsset.removeChild(this.uiAsset);
  28.          this.panelAsset = null;
  29.          this.uiAsset = null;
  30.       }
  31.       
  32.       public function get dialogModel() : Dialog
  33.       {
  34.          return Dialog(model);
  35.       }
  36.       
  37.       public function get dialogController() : DialogController
  38.       {
  39.          return DialogController(controller);
  40.       }
  41.       
  42.       override protected function createController() : void
  43.       {
  44.          controller = new DialogController(this);
  45.       }
  46.       
  47.       override protected function createView() : void
  48.       {
  49.          this.panelAsset = new DialogAsset();
  50.          this.panelAsset.cacheAsBitmap = true;
  51.          this.panelAsset.titleBtn.useHandCursor = false;
  52.          if(this.type == Dialog.NOTICE)
  53.          {
  54.             this.uiAsset = new NoticeDialogUI();
  55.             this.panelAsset.bg.width = 350;
  56.             this.panelAsset.bg.height = 150;
  57.             this.panelAsset.title.text = "";
  58.             this.panelAsset.helpBtn.visible = this.panelAsset.helpBtn.enabled = false;
  59.             this.panelAsset.toggleBtn.visible = this.panelAsset.toggleBtn.enabled = false;
  60.             this.enableDrag = true;
  61.             this.update(Update.dataUpdate(this.dialogModel.data));
  62.          }
  63.          else if(this.type == Dialog.LOADING)
  64.          {
  65.             this.uiAsset = new LoadingDialogUI();
  66.             this.panelAsset.bg.width = 350;
  67.             this.panelAsset.bg.height = 115;
  68.             this.panelAsset.title.text = "";
  69.             this.panelAsset.helpBtn.visible = this.panelAsset.helpBtn.enabled = false;
  70.             this.panelAsset.toggleBtn.visible = this.panelAsset.toggleBtn.enabled = false;
  71.             this.enableDrag = false;
  72.             this.update(Update.loadingUpdate(this.dialogModel.data));
  73.          }
  74.          else if(this.type == Dialog.PROCESS)
  75.          {
  76.             this.uiAsset = new ProcessDialogUI();
  77.             this.panelAsset.bg.width = 350;
  78.             this.panelAsset.bg.height = 115;
  79.             this.panelAsset.title.text = "";
  80.             this.panelAsset.helpBtn.visible = this.panelAsset.helpBtn.enabled = false;
  81.             this.panelAsset.toggleBtn.visible = this.panelAsset.toggleBtn.enabled = false;
  82.             this.enableDrag = false;
  83.             this.update(Update.dataUpdate(this.dialogModel.data));
  84.          }
  85.          else if(this.type == Dialog.QUESTION)
  86.          {
  87.             this.uiAsset = new QuestionDialogUI();
  88.             this.panelAsset.bg.width = 350;
  89.             this.panelAsset.bg.height = 150;
  90.             this.panelAsset.title.text = "";
  91.             this.panelAsset.helpBtn.visible = this.panelAsset.helpBtn.enabled = false;
  92.             this.panelAsset.toggleBtn.visible = this.panelAsset.toggleBtn.enabled = false;
  93.             this.enableDrag = true;
  94.             this.update(Update.dataUpdate(this.dialogModel.data));
  95.          }
  96.          this.uiAsset.x = 17;
  97.          this.uiAsset.y = 38;
  98.          this.uiAsset.cacheAsBitmap = true;
  99.          this.panelAsset.addChild(this.uiAsset);
  100.          this.panelAsset.x = UI.centerX - this.panelAsset.width / 2;
  101.          this.panelAsset.y = UI.centerY - this.panelAsset.height / 2;
  102.          UI.DIALOG_HOLDER.addChild(this.panelAsset);
  103.       }
  104.       
  105.       override public function update(update:Update = null) : void
  106.       {
  107.          try
  108.          {
  109.             if(update.type == UpdateEvent.DATA)
  110.             {
  111.                this.message = update.data.message;
  112.             }
  113.             else if(update.type == UpdateEvent.LOADING)
  114.             {
  115.                this.loadPercent = update.data.loadPercent;
  116.                this.message = update.data.message;
  117.             }
  118.             else if(update.type != UpdateEvent.WINDOW)
  119.             {
  120.                if(update.type != UpdateEvent.BRUSH_STYLE)
  121.                {
  122.                   if(update.type == UpdateEvent.PROJECT)
  123.                   {
  124.                   }
  125.                }
  126.             }
  127.          }
  128.          catch(e:Error)
  129.          {
  130.          }
  131.       }
  132.       
  133.       public function get loadBar() : MovieClip
  134.       {
  135.          return this.uiAsset["bar"];
  136.       }
  137.       
  138.       public function get messageField() : TextField
  139.       {
  140.          return this.uiAsset["message"];
  141.       }
  142.       
  143.       public function set message(s:String) : void
  144.       {
  145.          this.messageField.htmlText = s;
  146.       }
  147.       
  148.       public function get type() : String
  149.       {
  150.          return this.dialogModel.type;
  151.       }
  152.       
  153.       public function get id() : String
  154.       {
  155.          return this.dialogModel.id;
  156.       }
  157.       
  158.       public function set loadPercent(n:Number) : void
  159.       {
  160.          this.loadBar.scaleX = Math.min(n,1);
  161.       }
  162.    }
  163. }
  164.  
  165.