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

  1. package fl.controls
  2. {
  3.    import fl.controls.listClasses.ICellRenderer;
  4.    import fl.core.InvalidationType;
  5.    import fl.core.UIComponent;
  6.    import fl.data.DataProvider;
  7.    import fl.data.SimpleCollectionItem;
  8.    import fl.events.ComponentEvent;
  9.    import fl.events.DataChangeEvent;
  10.    import fl.events.ListEvent;
  11.    import fl.managers.IFocusManagerComponent;
  12.    import flash.display.DisplayObject;
  13.    import flash.events.Event;
  14.    import flash.events.FocusEvent;
  15.    import flash.events.KeyboardEvent;
  16.    import flash.events.MouseEvent;
  17.    import flash.geom.Point;
  18.    import flash.text.TextFormat;
  19.    import flash.ui.Keyboard;
  20.    
  21.    [Embed(source="/_assets/assets.swf", symbol="symbol348")]
  22.    public class ComboBox extends UIComponent implements IFocusManagerComponent
  23.    {
  24.       public static var createAccessibilityImplementation:Function;
  25.       
  26.       private static var defaultStyles:Object = {
  27.          "upSkin":"ComboBox_upSkin",
  28.          "downSkin":"ComboBox_downSkin",
  29.          "overSkin":"ComboBox_overSkin",
  30.          "disabledSkin":"ComboBox_disabledSkin",
  31.          "focusRectSkin":null,
  32.          "focusRectPadding":null,
  33.          "textFormat":null,
  34.          "disabledTextFormat":null,
  35.          "textPadding":3,
  36.          "buttonWidth":24,
  37.          "disabledAlpha":null,
  38.          "listSkin":null
  39.       };
  40.       
  41.       protected static const LIST_STYLES:Object = {
  42.          "upSkin":"comboListUpSkin",
  43.          "overSkin":"comboListOverSkin",
  44.          "downSkin":"comobListDownSkin",
  45.          "disabledSkin":"comboListDisabledSkin",
  46.          "downArrowDisabledSkin":"downArrowDisabledSkin",
  47.          "downArrowDownSkin":"downArrowDownSkin",
  48.          "downArrowOverSkin":"downArrowOverSkin",
  49.          "downArrowUpSkin":"downArrowUpSkin",
  50.          "upArrowDisabledSkin":"upArrowDisabledSkin",
  51.          "upArrowDownSkin":"upArrowDownSkin",
  52.          "upArrowOverSkin":"upArrowOverSkin",
  53.          "upArrowUpSkin":"upArrowUpSkin",
  54.          "thumbDisabledSkin":"thumbDisabledSkin",
  55.          "thumbDownSkin":"thumbDownSkin",
  56.          "thumbOverSkin":"thumbOverSkin",
  57.          "thumbUpSkin":"thumbUpSkin",
  58.          "thumbIcon":"thumbIcon",
  59.          "trackDisabledSkin":"trackDisabledSkin",
  60.          "trackDownSkin":"trackDownSkin",
  61.          "trackOverSkin":"trackOverSkin",
  62.          "trackUpSkin":"trackUpSkin",
  63.          "repeatDelay":"repeatDelay",
  64.          "repeatInterval":"repeatInterval",
  65.          "textFormat":"textFormat",
  66.          "disabledAlpha":"disabledAlpha",
  67.          "skin":"listSkin"
  68.       };
  69.       
  70.       protected static const BACKGROUND_STYLES:Object = {
  71.          "overSkin":"overSkin",
  72.          "downSkin":"downSkin",
  73.          "upSkin":"upSkin",
  74.          "disabledSkin":"disabledSkin",
  75.          "repeatInterval":"repeatInterval"
  76.       };
  77.       
  78.       protected var isKeyDown:Boolean = false;
  79.       
  80.       protected var _labels:Array;
  81.       
  82.       protected var background:BaseButton;
  83.       
  84.       protected var _dropdownWidth:Number;
  85.       
  86.       protected var inputField:TextInput;
  87.       
  88.       protected var highlightedCell:int = -1;
  89.       
  90.       protected var listOverIndex:uint;
  91.       
  92.       protected var editableValue:String;
  93.       
  94.       protected var _prompt:String;
  95.       
  96.       protected var isOpen:Boolean = false;
  97.       
  98.       protected var list:List;
  99.       
  100.       protected var _rowCount:uint = 5;
  101.       
  102.       protected var _editable:Boolean = false;
  103.       
  104.       private var collectionItemImport:SimpleCollectionItem;
  105.       
  106.       protected var currentIndex:int;
  107.       
  108.       public function ComboBox()
  109.       {
  110.          super();
  111.       }
  112.       
  113.       public static function getStyleDefinition() : Object
  114.       {
  115.          return mergeStyles(defaultStyles,List.getStyleDefinition());
  116.       }
  117.       
  118.       protected function drawList() : void
  119.       {
  120.          list.rowCount = Math.max(0,Math.min(_rowCount,list.dataProvider.length));
  121.       }
  122.       
  123.       public function get imeMode() : String
  124.       {
  125.          return inputField.imeMode;
  126.       }
  127.       
  128.       protected function onInputFieldFocusOut(param1:FocusEvent) : void
  129.       {
  130.          inputField.removeEventListener(ComponentEvent.ENTER,onEnter);
  131.          selectedIndex = selectedIndex;
  132.       }
  133.       
  134.       public function set imeMode(param1:String) : void
  135.       {
  136.          inputField.imeMode = param1;
  137.       }
  138.       
  139.       protected function passEvent(param1:Event) : void
  140.       {
  141.          dispatchEvent(param1);
  142.       }
  143.       
  144.       protected function calculateAvailableHeight() : Number
  145.       {
  146.          var _loc1_:Number = Number(getStyleValue("contentPadding"));
  147.          return list.height - _loc1_ * 2;
  148.       }
  149.       
  150.       public function get dropdown() : List
  151.       {
  152.          return list;
  153.       }
  154.       
  155.       override protected function focusOutHandler(param1:FocusEvent) : void
  156.       {
  157.          isKeyDown = false;
  158.          if(isOpen)
  159.          {
  160.             if(!param1.relatedObject || !list.contains(param1.relatedObject))
  161.             {
  162.                if(highlightedCell != -1 && highlightedCell != selectedIndex)
  163.                {
  164.                   selectedIndex = highlightedCell;
  165.                   dispatchEvent(new Event(Event.CHANGE));
  166.                }
  167.                close();
  168.             }
  169.          }
  170.          super.focusOutHandler(param1);
  171.       }
  172.       
  173.       public function get selectedLabel() : String
  174.       {
  175.          if(editableValue != null)
  176.          {
  177.             return editableValue;
  178.          }
  179.          if(selectedIndex == -1)
  180.          {
  181.             return null;
  182.          }
  183.          return itemToLabel(selectedItem);
  184.       }
  185.       
  186.       protected function onListChange(param1:Event) : void
  187.       {
  188.          editableValue = null;
  189.          dispatchEvent(param1);
  190.          invalidate(InvalidationType.SELECTED);
  191.          if(isKeyDown)
  192.          {
  193.             return;
  194.          }
  195.          close();
  196.       }
  197.       
  198.       public function get text() : String
  199.       {
  200.          return inputField.text;
  201.       }
  202.       
  203.       protected function onEnter(param1:ComponentEvent) : void
  204.       {
  205.          param1.stopPropagation();
  206.       }
  207.       
  208.       public function sortItemsOn(param1:String, param2:Object = null) : *
  209.       {
  210.          return list.sortItemsOn(param1,param2);
  211.       }
  212.       
  213.       protected function handleDataChange(param1:DataChangeEvent) : void
  214.       {
  215.          invalidate(InvalidationType.DATA);
  216.       }
  217.       
  218.       protected function onToggleListVisibility(param1:MouseEvent) : void
  219.       {
  220.          param1.stopPropagation();
  221.          dispatchEvent(param1);
  222.          if(isOpen)
  223.          {
  224.             close();
  225.          }
  226.          else
  227.          {
  228.             open();
  229.             stage.addEventListener(MouseEvent.MOUSE_UP,onListItemUp,false,0,true);
  230.          }
  231.       }
  232.       
  233.       public function get dropdownWidth() : Number
  234.       {
  235.          return list.width;
  236.       }
  237.       
  238.       protected function highlightCell(param1:int = -1) : void
  239.       {
  240.          var _loc2_:ICellRenderer = null;
  241.          if(highlightedCell > -1)
  242.          {
  243.             _loc2_ = list.itemToCellRenderer(getItemAt(highlightedCell));
  244.             if(_loc2_ != null)
  245.             {
  246.                _loc2_.setMouseState("up");
  247.             }
  248.          }
  249.          if(param1 == -1)
  250.          {
  251.             return;
  252.          }
  253.          list.scrollToIndex(param1);
  254.          list.drawNow();
  255.          _loc2_ = list.itemToCellRenderer(getItemAt(param1));
  256.          if(_loc2_ != null)
  257.          {
  258.             _loc2_.setMouseState("over");
  259.             highlightedCell = param1;
  260.          }
  261.       }
  262.       
  263.       public function removeItemAt(param1:uint) : void
  264.       {
  265.          list.removeItemAt(param1);
  266.          invalidate(InvalidationType.DATA);
  267.       }
  268.       
  269.       override protected function draw() : void
  270.       {
  271.          var _loc1_:* = selectedIndex;
  272.          if(_loc1_ == -1 && (prompt != null || editable || length == 0))
  273.          {
  274.             _loc1_ = Math.max(-1,Math.min(_loc1_,length - 1));
  275.          }
  276.          else
  277.          {
  278.             editableValue = null;
  279.             _loc1_ = Math.max(0,Math.min(_loc1_,length - 1));
  280.          }
  281.          if(list.selectedIndex != _loc1_)
  282.          {
  283.             list.selectedIndex = _loc1_;
  284.             invalidate(InvalidationType.SELECTED,false);
  285.          }
  286.          if(isInvalid(InvalidationType.STYLES))
  287.          {
  288.             setStyles();
  289.             setEmbedFonts();
  290.             invalidate(InvalidationType.SIZE,false);
  291.          }
  292.          if(isInvalid(InvalidationType.SIZE,InvalidationType.DATA,InvalidationType.STATE))
  293.          {
  294.             drawTextFormat();
  295.             drawLayout();
  296.             invalidate(InvalidationType.DATA);
  297.          }
  298.          if(isInvalid(InvalidationType.DATA))
  299.          {
  300.             drawList();
  301.             invalidate(InvalidationType.SELECTED,true);
  302.          }
  303.          if(isInvalid(InvalidationType.SELECTED))
  304.          {
  305.             if(_loc1_ == -1 && editableValue != null)
  306.             {
  307.                inputField.text = editableValue;
  308.             }
  309.             else if(_loc1_ > -1)
  310.             {
  311.                if(length > 0)
  312.                {
  313.                   inputField.horizontalScrollPosition = 0;
  314.                   inputField.text = itemToLabel(list.selectedItem);
  315.                }
  316.             }
  317.             else if(_loc1_ == -1 && _prompt != null)
  318.             {
  319.                showPrompt();
  320.             }
  321.             else
  322.             {
  323.                inputField.text = "";
  324.             }
  325.             if(editable && selectedIndex > -1 && stage.focus == inputField.textField)
  326.             {
  327.                inputField.setSelection(0,inputField.length);
  328.             }
  329.          }
  330.          drawTextField();
  331.          super.draw();
  332.       }
  333.       
  334.       public function get selectedItem() : Object
  335.       {
  336.          return list.selectedItem;
  337.       }
  338.       
  339.       public function open() : void
  340.       {
  341.          currentIndex = selectedIndex;
  342.          if(isOpen || length == 0)
  343.          {
  344.             return;
  345.          }
  346.          dispatchEvent(new Event(Event.OPEN));
  347.          isOpen = true;
  348.          addEventListener(Event.ENTER_FRAME,addCloseListener,false,0,true);
  349.          positionList();
  350.          list.scrollToSelected();
  351.          stage.addChild(list);
  352.       }
  353.       
  354.       override protected function configUI() : void
  355.       {
  356.          super.configUI();
  357.          background = new BaseButton();
  358.          background.focusEnabled = false;
  359.          copyStylesToChild(background,BACKGROUND_STYLES);
  360.          background.addEventListener(MouseEvent.MOUSE_DOWN,onToggleListVisibility,false,0,true);
  361.          addChild(background);
  362.          inputField = new TextInput();
  363.          inputField.focusTarget = this as IFocusManagerComponent;
  364.          inputField.focusEnabled = false;
  365.          inputField.addEventListener(Event.CHANGE,onTextInput,false,0,true);
  366.          addChild(inputField);
  367.          list = new List();
  368.          list.focusEnabled = false;
  369.          copyStylesToChild(list,LIST_STYLES);
  370.          list.addEventListener(Event.CHANGE,onListChange,false,0,true);
  371.          list.addEventListener(ListEvent.ITEM_CLICK,onListChange,false,0,true);
  372.          list.addEventListener(ListEvent.ITEM_ROLL_OUT,passEvent,false,0,true);
  373.          list.addEventListener(ListEvent.ITEM_ROLL_OVER,passEvent,false,0,true);
  374.          list.verticalScrollBar.addEventListener(Event.SCROLL,passEvent,false,0,true);
  375.       }
  376.       
  377.       public function set text(param1:String) : void
  378.       {
  379.          if(!editable)
  380.          {
  381.             return;
  382.          }
  383.          inputField.text = param1;
  384.       }
  385.       
  386.       public function addItem(param1:Object) : void
  387.       {
  388.          list.addItem(param1);
  389.          invalidate(InvalidationType.DATA);
  390.       }
  391.       
  392.       public function get editable() : Boolean
  393.       {
  394.          return _editable;
  395.       }
  396.       
  397.       public function get labelField() : String
  398.       {
  399.          return list.labelField;
  400.       }
  401.       
  402.       protected function positionList() : void
  403.       {
  404.          var _loc1_:Point = localToGlobal(new Point(0,0));
  405.          list.x = _loc1_.x;
  406.          if(_loc1_.y + height + list.height > stage.stageHeight)
  407.          {
  408.             list.y = _loc1_.y - list.height;
  409.          }
  410.          else
  411.          {
  412.             list.y = _loc1_.y + height;
  413.          }
  414.       }
  415.       
  416.       protected function onStageClick(param1:MouseEvent) : void
  417.       {
  418.          if(!isOpen)
  419.          {
  420.             return;
  421.          }
  422.          if(!contains(param1.target as DisplayObject) && !list.contains(param1.target as DisplayObject))
  423.          {
  424.             if(highlightedCell != -1)
  425.             {
  426.                selectedIndex = highlightedCell;
  427.                dispatchEvent(new Event(Event.CHANGE));
  428.             }
  429.             close();
  430.          }
  431.       }
  432.       
  433.       public function set dropdownWidth(param1:Number) : void
  434.       {
  435.          _dropdownWidth = param1;
  436.          invalidate(InvalidationType.SIZE);
  437.       }
  438.       
  439.       public function get prompt() : String
  440.       {
  441.          return _prompt;
  442.       }
  443.       
  444.       override protected function keyDownHandler(param1:KeyboardEvent) : void
  445.       {
  446.          isKeyDown = true;
  447.          if(param1.ctrlKey)
  448.          {
  449.             switch(param1.keyCode)
  450.             {
  451.                case Keyboard.UP:
  452.                   if(highlightedCell > -1)
  453.                   {
  454.                      selectedIndex = highlightedCell;
  455.                      dispatchEvent(new Event(Event.CHANGE));
  456.                   }
  457.                   close();
  458.                   break;
  459.                case Keyboard.DOWN:
  460.                   open();
  461.             }
  462.             return;
  463.          }
  464.          param1.stopPropagation();
  465.          var _loc2_:int = Math.max(calculateAvailableHeight() / list.rowHeight << 0,1);
  466.          var _loc3_:uint = uint(selectedIndex);
  467.          var _loc4_:Number = highlightedCell == -1 ? selectedIndex : highlightedCell;
  468.          var _loc5_:int = -1;
  469.          switch(param1.keyCode)
  470.          {
  471.             case Keyboard.SPACE:
  472.                if(isOpen)
  473.                {
  474.                   close();
  475.                }
  476.                else
  477.                {
  478.                   open();
  479.                }
  480.                return;
  481.             case Keyboard.ESCAPE:
  482.                if(isOpen)
  483.                {
  484.                   if(highlightedCell > -1)
  485.                   {
  486.                      selectedIndex = selectedIndex;
  487.                   }
  488.                   close();
  489.                }
  490.                return;
  491.             case Keyboard.UP:
  492.                _loc5_ = Math.max(0,_loc4_ - 1);
  493.                break;
  494.             case Keyboard.DOWN:
  495.                _loc5_ = Math.min(length - 1,_loc4_ + 1);
  496.                break;
  497.             case Keyboard.PAGE_UP:
  498.                _loc5_ = Math.max(_loc4_ - _loc2_,0);
  499.                break;
  500.             case Keyboard.PAGE_DOWN:
  501.                _loc5_ = Math.min(_loc4_ + _loc2_,length - 1);
  502.                break;
  503.             case Keyboard.HOME:
  504.                _loc5_ = 0;
  505.                break;
  506.             case Keyboard.END:
  507.                _loc5_ = length - 1;
  508.                break;
  509.             case Keyboard.ENTER:
  510.                if(_editable && highlightedCell == -1)
  511.                {
  512.                   editableValue = inputField.text;
  513.                   selectedIndex = -1;
  514.                }
  515.                else if(isOpen && highlightedCell > -1)
  516.                {
  517.                   editableValue = null;
  518.                   selectedIndex = highlightedCell;
  519.                   dispatchEvent(new Event(Event.CHANGE));
  520.                }
  521.                dispatchEvent(new ComponentEvent(ComponentEvent.ENTER));
  522.                close();
  523.                return;
  524.             default:
  525.                if(editable)
  526.                {
  527.                   break;
  528.                }
  529.                _loc5_ = list.getNextIndexAtLetter(String.fromCharCode(param1.keyCode),_loc4_);
  530.                break;
  531.          }
  532.          if(_loc5_ > -1)
  533.          {
  534.             if(isOpen)
  535.             {
  536.                highlightCell(_loc5_);
  537.                inputField.text = list.itemToLabel(getItemAt(_loc5_));
  538.             }
  539.             else
  540.             {
  541.                highlightCell();
  542.                selectedIndex = _loc5_;
  543.                dispatchEvent(new Event(Event.CHANGE));
  544.             }
  545.          }
  546.       }
  547.       
  548.       public function get value() : String
  549.       {
  550.          var _loc1_:Object = null;
  551.          if(editableValue != null)
  552.          {
  553.             return editableValue;
  554.          }
  555.          _loc1_ = selectedItem;
  556.          if(!_editable && _loc1_.data != null)
  557.          {
  558.             return _loc1_.data;
  559.          }
  560.          return itemToLabel(_loc1_);
  561.       }
  562.       
  563.       override protected function focusInHandler(param1:FocusEvent) : void
  564.       {
  565.          super.focusInHandler(param1);
  566.          if(editable)
  567.          {
  568.             stage.focus = inputField.textField;
  569.          }
  570.       }
  571.       
  572.       public function set dataProvider(param1:DataProvider) : void
  573.       {
  574.          param1.addEventListener(DataChangeEvent.DATA_CHANGE,handleDataChange,false,0,true);
  575.          list.dataProvider = param1;
  576.          invalidate(InvalidationType.DATA);
  577.       }
  578.       
  579.       public function get rowCount() : uint
  580.       {
  581.          return _rowCount;
  582.       }
  583.       
  584.       public function set restrict(param1:String) : void
  585.       {
  586.          if(componentInspectorSetting && param1 == "")
  587.          {
  588.             param1 = null;
  589.          }
  590.          if(!_editable)
  591.          {
  592.             return;
  593.          }
  594.          inputField.restrict = param1;
  595.       }
  596.       
  597.       public function replaceItemAt(param1:Object, param2:uint) : Object
  598.       {
  599.          return list.replaceItemAt(param1,param2);
  600.       }
  601.       
  602.       public function removeAll() : void
  603.       {
  604.          list.removeAll();
  605.          inputField.text = "";
  606.          invalidate(InvalidationType.DATA);
  607.       }
  608.       
  609.       protected function onTextInput(param1:Event) : void
  610.       {
  611.          param1.stopPropagation();
  612.          if(!_editable)
  613.          {
  614.             return;
  615.          }
  616.          editableValue = inputField.text;
  617.          selectedIndex = -1;
  618.          dispatchEvent(new Event(Event.CHANGE));
  619.       }
  620.       
  621.       protected function onInputFieldFocus(param1:FocusEvent) : void
  622.       {
  623.          inputField.addEventListener(ComponentEvent.ENTER,onEnter,false,0,true);
  624.          close();
  625.       }
  626.       
  627.       protected function onListItemUp(param1:MouseEvent) : void
  628.       {
  629.          stage.removeEventListener(MouseEvent.MOUSE_UP,onListItemUp);
  630.          if(!(param1.target is ICellRenderer) || !list.contains(param1.target as DisplayObject))
  631.          {
  632.             return;
  633.          }
  634.          editableValue = null;
  635.          var _loc2_:* = selectedIndex;
  636.          selectedIndex = param1.target.listData.index;
  637.          if(_loc2_ != selectedIndex)
  638.          {
  639.             dispatchEvent(new Event(Event.CHANGE));
  640.          }
  641.          close();
  642.       }
  643.       
  644.       override protected function keyUpHandler(param1:KeyboardEvent) : void
  645.       {
  646.          isKeyDown = false;
  647.       }
  648.       
  649.       protected function drawLayout() : void
  650.       {
  651.          var _loc1_:Number = getStyleValue("buttonWidth") as Number;
  652.          var _loc2_:Number = getStyleValue("textPadding") as Number;
  653.          background.setSize(width,height);
  654.          inputField.x = inputField.y = _loc2_;
  655.          inputField.setSize(width - _loc1_ - _loc2_,height - _loc2_);
  656.          list.width = isNaN(_dropdownWidth) ? width : _dropdownWidth;
  657.          background.enabled = enabled;
  658.          background.drawNow();
  659.       }
  660.       
  661.       public function set selectedItem(param1:Object) : void
  662.       {
  663.          list.selectedItem = param1;
  664.          invalidate(InvalidationType.SELECTED);
  665.       }
  666.       
  667.       public function getItemAt(param1:uint) : Object
  668.       {
  669.          return list.getItemAt(param1);
  670.       }
  671.       
  672.       override protected function initializeAccessibility() : void
  673.       {
  674.          if(ComboBox.createAccessibilityImplementation != null)
  675.          {
  676.             ComboBox.createAccessibilityImplementation(this);
  677.          }
  678.       }
  679.       
  680.       public function itemToLabel(param1:Object) : String
  681.       {
  682.          if(param1 == null)
  683.          {
  684.             return "";
  685.          }
  686.          return list.itemToLabel(param1);
  687.       }
  688.       
  689.       public function addItemAt(param1:Object, param2:uint) : void
  690.       {
  691.          list.addItemAt(param1,param2);
  692.          invalidate(InvalidationType.DATA);
  693.       }
  694.       
  695.       private function addCloseListener(param1:Event) : *
  696.       {
  697.          removeEventListener(Event.ENTER_FRAME,addCloseListener);
  698.          if(!isOpen)
  699.          {
  700.             return;
  701.          }
  702.          stage.addEventListener(MouseEvent.MOUSE_DOWN,onStageClick,false,0,true);
  703.       }
  704.       
  705.       protected function setEmbedFonts() : void
  706.       {
  707.          var _loc1_:Object = getStyleValue("embedFonts");
  708.          if(_loc1_ != null)
  709.          {
  710.             inputField.textField.embedFonts = _loc1_;
  711.          }
  712.       }
  713.       
  714.       public function set rowCount(param1:uint) : void
  715.       {
  716.          _rowCount = param1;
  717.          invalidate(InvalidationType.SIZE);
  718.       }
  719.       
  720.       public function removeItem(param1:Object) : Object
  721.       {
  722.          return list.removeItem(param1);
  723.       }
  724.       
  725.       public function get dataProvider() : DataProvider
  726.       {
  727.          return list.dataProvider;
  728.       }
  729.       
  730.       public function get restrict() : String
  731.       {
  732.          return inputField.restrict;
  733.       }
  734.       
  735.       protected function showPrompt() : void
  736.       {
  737.          inputField.text = _prompt;
  738.       }
  739.       
  740.       public function sortItems(... rest) : *
  741.       {
  742.          return list.sortItems.apply(list,rest);
  743.       }
  744.       
  745.       public function set editable(param1:Boolean) : void
  746.       {
  747.          _editable = param1;
  748.          drawTextField();
  749.       }
  750.       
  751.       public function set labelField(param1:String) : void
  752.       {
  753.          list.labelField = param1;
  754.          invalidate(InvalidationType.DATA);
  755.       }
  756.       
  757.       public function get textField() : TextInput
  758.       {
  759.          return inputField;
  760.       }
  761.       
  762.       public function set prompt(param1:String) : void
  763.       {
  764.          if(param1 == "")
  765.          {
  766.             _prompt = null;
  767.          }
  768.          else
  769.          {
  770.             _prompt = param1;
  771.          }
  772.          invalidate(InvalidationType.STATE);
  773.       }
  774.       
  775.       public function set labelFunction(param1:Function) : void
  776.       {
  777.          list.labelFunction = param1;
  778.          invalidate(InvalidationType.DATA);
  779.       }
  780.       
  781.       protected function setStyles() : void
  782.       {
  783.          copyStylesToChild(background,BACKGROUND_STYLES);
  784.          copyStylesToChild(list,LIST_STYLES);
  785.       }
  786.       
  787.       public function get length() : int
  788.       {
  789.          return list.length;
  790.       }
  791.       
  792.       protected function drawTextFormat() : void
  793.       {
  794.          var _loc1_:TextFormat = getStyleValue(_enabled ? "textFormat" : "disabledTextFormat") as TextFormat;
  795.          if(_loc1_ == null)
  796.          {
  797.             _loc1_ = new TextFormat();
  798.          }
  799.          inputField.textField.defaultTextFormat = _loc1_;
  800.          inputField.textField.setTextFormat(_loc1_);
  801.          setEmbedFonts();
  802.       }
  803.       
  804.       protected function drawTextField() : void
  805.       {
  806.          inputField.setStyle("upSkin","");
  807.          inputField.setStyle("disabledSkin","");
  808.          inputField.enabled = enabled;
  809.          inputField.editable = _editable;
  810.          inputField.textField.selectable = enabled && _editable;
  811.          inputField.mouseEnabled = inputField.mouseChildren = enabled && _editable;
  812.          inputField.focusEnabled = false;
  813.          if(_editable)
  814.          {
  815.             inputField.addEventListener(FocusEvent.FOCUS_IN,onInputFieldFocus,false,0,true);
  816.             inputField.addEventListener(FocusEvent.FOCUS_OUT,onInputFieldFocusOut,false,0,true);
  817.          }
  818.          else
  819.          {
  820.             inputField.removeEventListener(FocusEvent.FOCUS_IN,onInputFieldFocus);
  821.             inputField.removeEventListener(FocusEvent.FOCUS_OUT,onInputFieldFocusOut);
  822.          }
  823.       }
  824.       
  825.       public function get labelFunction() : Function
  826.       {
  827.          return list.labelFunction;
  828.       }
  829.       
  830.       public function set selectedIndex(param1:int) : void
  831.       {
  832.          list.selectedIndex = param1;
  833.          highlightCell();
  834.          invalidate(InvalidationType.SELECTED);
  835.       }
  836.       
  837.       public function get selectedIndex() : int
  838.       {
  839.          return list.selectedIndex;
  840.       }
  841.       
  842.       public function close() : void
  843.       {
  844.          highlightCell();
  845.          highlightedCell = -1;
  846.          if(!isOpen)
  847.          {
  848.             return;
  849.          }
  850.          dispatchEvent(new Event(Event.CLOSE));
  851.          stage.removeEventListener(MouseEvent.MOUSE_DOWN,onStageClick);
  852.          isOpen = false;
  853.          stage.removeChild(list);
  854.       }
  855.    }
  856. }
  857.  
  858.