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 / DecoStyleController.as < prev    next >
Encoding:
Text File  |  2009-10-26  |  3.5 KB  |  102 lines

  1. package com.livebrush.ui
  2. {
  3.    import com.livebrush.data.FileManager;
  4.    import com.livebrush.events.ListEvent;
  5.    import com.livebrush.utils.ColorObj;
  6.    import flash.events.Event;
  7.    
  8.    public class DecoStyleController extends UIController
  9.    {
  10.       public function DecoStyleController(decoStyleView:DecoStyleView)
  11.       {
  12.          super(decoStyleView);
  13.          this.init();
  14.       }
  15.       
  16.       override protected function init() : void
  17.       {
  18.          this.uiAsset.addEventListener(Event.CHANGE,this.propsChangeEvent);
  19.          this.uiAsset.positionInputs.addEventListener(Event.CHANGE,this.propsChangeEvent);
  20.          this.uiAsset.angleInputs.addEventListener(Event.CHANGE,this.propsChangeEvent);
  21.          this.uiAsset.sizeInputs.addEventListener(Event.CHANGE,this.propsChangeEvent);
  22.          this.uiAsset.alphaInputs.addEventListener(Event.CHANGE,this.propsChangeEvent);
  23.          this.uiAsset.tintInputs.addEventListener(Event.CHANGE,this.propsChangeEvent);
  24.          this.uiAsset.alignInputs.addEventListener(Event.CHANGE,this.propsChangeEvent);
  25.          this.decoStyleView.colorInputs.addEventListener(ListEvent.ADD,this.addColor);
  26.          this.decoStyleView.colorInputs.addEventListener(ListEvent.REMOVE,this.removeColor);
  27.          this.decoStyleView.colorInputs.addEventListener(Event.CHANGE,this.propsChangeEvent);
  28.          this.decoStyleView.decoInputs.addEventListener(ListEvent.ADD,this.addDeco);
  29.          this.decoStyleView.decoInputs.addEventListener(ListEvent.REMOVE,this.removeDeco);
  30.          this.decoStyleView.decoInputs.addEventListener(Event.CHANGE,this.propsChangeEvent);
  31.       }
  32.       
  33.       private function propsChangeEvent(e:Event) : void
  34.       {
  35.          e.stopImmediatePropagation();
  36.          this.decoStyleView.applyProps();
  37.          this.brushPropsModel.pullStyleProps();
  38.       }
  39.       
  40.       private function addColor(e:ListEvent) : void
  41.       {
  42.          try
  43.          {
  44.             this.decoStyleView.colorInputs.addItemAt(this.decoStyleView.colorInputs.list[this.decoStyleView.colorInputs.selectedIndex].copy(),this.decoStyleView.colorInputs.selectedIndex);
  45.          }
  46.          catch(e:Error)
  47.          {
  48.             decoStyleView.colorInputs.addItemAt(decoStyleView.colorInputs.list[0].copy(),0);
  49.          }
  50.          catch(e:Error)
  51.          {
  52.             decoStyleView.colorInputs.addItemAt(new ColorObj(16711680,true),0);
  53.          }
  54.       }
  55.       
  56.       private function get brushPropsModel() : BrushPropsModel
  57.       {
  58.          return this.decoStyleView.brushPropsModel;
  59.       }
  60.       
  61.       private function removeDeco(e:ListEvent) : void
  62.       {
  63.          try
  64.          {
  65.             this.decoStyleView.decoInputs.removeItemsAt(this.decoStyleView.decoInputs.selectedIndex,1);
  66.          }
  67.          catch(e:Error)
  68.          {
  69.             decoStyleView.decoInputs.removeItemsAt(0,1);
  70.          }
  71.       }
  72.       
  73.       private function get decoStyleView() : DecoStyleView
  74.       {
  75.          return DecoStyleView(view);
  76.       }
  77.       
  78.       private function get uiAsset() : Object
  79.       {
  80.          return this.decoStyleView.uiAsset;
  81.       }
  82.       
  83.       private function addDeco(e:ListEvent) : void
  84.       {
  85.          ui.main.importToProject(FileManager.DECO);
  86.       }
  87.       
  88.       private function removeColor(e:ListEvent) : void
  89.       {
  90.          try
  91.          {
  92.             this.decoStyleView.colorInputs.removeItemsAt(this.decoStyleView.colorInputs.selectedIndex,1);
  93.          }
  94.          catch(e:Error)
  95.          {
  96.             decoStyleView.colorInputs.removeItemsAt(0,1);
  97.          }
  98.       }
  99.    }
  100. }
  101.  
  102.