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 / LineStyleController.as < prev    next >
Encoding:
Text File  |  2009-10-26  |  2.9 KB  |  86 lines

  1. package com.livebrush.ui
  2. {
  3.    import com.livebrush.events.ListEvent;
  4.    import com.livebrush.utils.ColorObj;
  5.    import flash.events.Event;
  6.    import flash.events.MouseEvent;
  7.    
  8.    public class LineStyleController extends UIController
  9.    {
  10.       public function LineStyleController(lineStyleView:LineStyleView)
  11.       {
  12.          super(lineStyleView);
  13.          this.init();
  14.       }
  15.       
  16.       override protected function init() : void
  17.       {
  18.          this.uiAsset.addEventListener(Event.CHANGE,this.propsChangeEvent);
  19.          this.uiAsset.lineType.addEventListener(Event.CHANGE,this.propsChangeEvent);
  20.          this.uiAsset.strokeInputs.addEventListener(Event.CHANGE,this.propsChangeEvent);
  21.          this.uiAsset.widthInputs.addEventListener(Event.CHANGE,this.propsChangeEvent);
  22.          this.uiAsset.angleInputs.addEventListener(Event.CHANGE,this.propsChangeEvent);
  23.          this.uiAsset.alphaInputs.addEventListener(Event.CHANGE,this.propsChangeEvent);
  24.          this.lineStyleView.colorInputs.typeInput.addEventListener(Event.CHANGE,this.propsChangeEvent);
  25.          this.lineStyleView.colorInputs.addEventListener(ListEvent.ADD,this.addColor);
  26.          this.lineStyleView.colorInputs.addEventListener(ListEvent.REMOVE,this.removeColor);
  27.          this.lineStyleView.colorInputs.addEventListener(Event.CHANGE,this.propsChangeEvent);
  28.       }
  29.       
  30.       private function get lineStyleView() : LineStyleView
  31.       {
  32.          return LineStyleView(view);
  33.       }
  34.       
  35.       private function mouseEvent(e:MouseEvent) : void
  36.       {
  37.       }
  38.       
  39.       private function addColor(e:ListEvent) : void
  40.       {
  41.          try
  42.          {
  43.             this.lineStyleView.colorInputs.addItemAt(this.lineStyleView.colorInputs.list[this.lineStyleView.colorInputs.selectedIndex].copy(),this.lineStyleView.colorInputs.selectedIndex);
  44.          }
  45.          catch(e:Error)
  46.          {
  47.             lineStyleView.colorInputs.addItemAt(lineStyleView.colorInputs.list[0].copy(),0);
  48.          }
  49.          catch(e:Error)
  50.          {
  51.             lineStyleView.colorInputs.addItemAt(new ColorObj(16711680,true),0);
  52.          }
  53.       }
  54.       
  55.       private function propsChangeEvent(e:Event) : void
  56.       {
  57.          e.stopImmediatePropagation();
  58.          this.lineStyleView.applyProps();
  59.          this.brushPropsModel.pullStyleProps();
  60.       }
  61.       
  62.       private function get brushPropsModel() : BrushPropsModel
  63.       {
  64.          return this.lineStyleView.brushPropsModel;
  65.       }
  66.       
  67.       private function get uiAsset() : Object
  68.       {
  69.          return this.lineStyleView.uiAsset;
  70.       }
  71.       
  72.       private function removeColor(e:ListEvent) : void
  73.       {
  74.          try
  75.          {
  76.             this.lineStyleView.colorInputs.removeItemsAt(this.lineStyleView.colorInputs.selectedIndex,1);
  77.          }
  78.          catch(e:Error)
  79.          {
  80.             lineStyleView.colorInputs.removeItemsAt(0,1);
  81.          }
  82.       }
  83.    }
  84. }
  85.  
  86.