home *** CD-ROM | disk | FTP | other *** search
- package com.livebrush.ui
- {
- import com.livebrush.events.UpdateEvent;
- import com.livebrush.utils.Update;
- import flash.display.MovieClip;
- import flash.display.Sprite;
- import flash.text.TextField;
-
- public class DialogView extends UIView
- {
- public var panelAsset:DialogAsset;
-
- public var enableDrag:Boolean = true;
-
- public var uiAsset:Sprite;
-
- public function DialogView(dialogModel:Dialog)
- {
- super(dialogModel);
- init();
- }
-
- override public function die() : void
- {
- this.dialogController.die();
- UI.DIALOG_HOLDER.removeChild(this.panelAsset);
- this.panelAsset.removeChild(this.uiAsset);
- this.panelAsset = null;
- this.uiAsset = null;
- }
-
- public function get dialogModel() : Dialog
- {
- return Dialog(model);
- }
-
- public function get dialogController() : DialogController
- {
- return DialogController(controller);
- }
-
- override protected function createController() : void
- {
- controller = new DialogController(this);
- }
-
- override protected function createView() : void
- {
- this.panelAsset = new DialogAsset();
- this.panelAsset.cacheAsBitmap = true;
- this.panelAsset.titleBtn.useHandCursor = false;
- if(this.type == Dialog.NOTICE)
- {
- this.uiAsset = new NoticeDialogUI();
- this.panelAsset.bg.width = 350;
- this.panelAsset.bg.height = 150;
- this.panelAsset.title.text = "";
- this.panelAsset.helpBtn.visible = this.panelAsset.helpBtn.enabled = false;
- this.panelAsset.toggleBtn.visible = this.panelAsset.toggleBtn.enabled = false;
- this.enableDrag = true;
- this.update(Update.dataUpdate(this.dialogModel.data));
- }
- else if(this.type == Dialog.LOADING)
- {
- this.uiAsset = new LoadingDialogUI();
- this.panelAsset.bg.width = 350;
- this.panelAsset.bg.height = 115;
- this.panelAsset.title.text = "";
- this.panelAsset.helpBtn.visible = this.panelAsset.helpBtn.enabled = false;
- this.panelAsset.toggleBtn.visible = this.panelAsset.toggleBtn.enabled = false;
- this.enableDrag = false;
- this.update(Update.loadingUpdate(this.dialogModel.data));
- }
- else if(this.type == Dialog.PROCESS)
- {
- this.uiAsset = new ProcessDialogUI();
- this.panelAsset.bg.width = 350;
- this.panelAsset.bg.height = 115;
- this.panelAsset.title.text = "";
- this.panelAsset.helpBtn.visible = this.panelAsset.helpBtn.enabled = false;
- this.panelAsset.toggleBtn.visible = this.panelAsset.toggleBtn.enabled = false;
- this.enableDrag = false;
- this.update(Update.dataUpdate(this.dialogModel.data));
- }
- else if(this.type == Dialog.QUESTION)
- {
- this.uiAsset = new QuestionDialogUI();
- this.panelAsset.bg.width = 350;
- this.panelAsset.bg.height = 150;
- this.panelAsset.title.text = "";
- this.panelAsset.helpBtn.visible = this.panelAsset.helpBtn.enabled = false;
- this.panelAsset.toggleBtn.visible = this.panelAsset.toggleBtn.enabled = false;
- this.enableDrag = true;
- this.update(Update.dataUpdate(this.dialogModel.data));
- }
- this.uiAsset.x = 17;
- this.uiAsset.y = 38;
- this.uiAsset.cacheAsBitmap = true;
- this.panelAsset.addChild(this.uiAsset);
- this.panelAsset.x = UI.centerX - this.panelAsset.width / 2;
- this.panelAsset.y = UI.centerY - this.panelAsset.height / 2;
- UI.DIALOG_HOLDER.addChild(this.panelAsset);
- }
-
- override public function update(update:Update = null) : void
- {
- try
- {
- if(update.type == UpdateEvent.DATA)
- {
- this.message = update.data.message;
- }
- else if(update.type == UpdateEvent.LOADING)
- {
- this.loadPercent = update.data.loadPercent;
- this.message = update.data.message;
- }
- else if(update.type != UpdateEvent.WINDOW)
- {
- if(update.type != UpdateEvent.BRUSH_STYLE)
- {
- if(update.type == UpdateEvent.PROJECT)
- {
- }
- }
- }
- }
- catch(e:Error)
- {
- }
- }
-
- public function get loadBar() : MovieClip
- {
- return this.uiAsset["bar"];
- }
-
- public function get messageField() : TextField
- {
- return this.uiAsset["message"];
- }
-
- public function set message(s:String) : void
- {
- this.messageField.htmlText = s;
- }
-
- public function get type() : String
- {
- return this.dialogModel.type;
- }
-
- public function get id() : String
- {
- return this.dialogModel.id;
- }
-
- public function set loadPercent(n:Number) : void
- {
- this.loadBar.scaleX = Math.min(n,1);
- }
- }
- }
-
-