home *** CD-ROM | disk | FTP | other *** search
- package com.livebrush.ui
- {
- import fl.controls.CheckBox;
- import fl.controls.TextInput;
- import flash.display.Sprite;
- import flash.events.Event;
- import org.casalib.util.NumberUtil;
-
- [Embed(source="/_assets/assets.swf", symbol="symbol384")]
- public class ThresholdInputs extends Sprite
- {
- public var _min:TextInput;
-
- public var minIn:Number = 0;
-
- public var _max:TextInput;
-
- public var maxIn:Number = 1000;
-
- public var _active:CheckBox;
-
- public var validRE:RegExp;
-
- public function ThresholdInputs()
- {
- super();
- this.init();
- this.__setProp__active_ThresholdInputs_Layer1_0();
- }
-
- public function get enabled() : Boolean
- {
- return this._active.enabled;
- }
-
- public function set enabled(b:Boolean) : void
- {
- this._max.enabled = this._min.enabled = this._active.enabled = b;
- }
-
- public function get active() : Boolean
- {
- return this._active.selected;
- }
-
- public function set max(n:Number) : void
- {
- this._max.text = String(n);
- }
-
- private function _setActive(b:Boolean) : void
- {
- this._active.selected = b;
- this._max.enabled = this._min.enabled = this._active.selected;
- }
-
- public function set active(b:Boolean) : void
- {
- this._setActive(b);
- }
-
- private function init() : void
- {
- this.validRE = /((([\.]+(0*))$)|(([\.]+[\d]+0)$)|(-$))/;
- this.active = false;
- this._min.restrict = this._max.restrict = "-.0123456789";
- addEventListener(Event.CHANGE,this.activeChange);
- }
-
- private function activeChange(e:Event) : void
- {
- if(e.target == this._active)
- {
- this._setActive(this._active.selected);
- }
- else if(e.target == this._min && !this.validInput(this._min))
- {
- e.stopImmediatePropagation();
- }
- else if(e.target == this._max && !this.validInput(this._max))
- {
- e.stopImmediatePropagation();
- }
- }
-
- public function get min() : Number
- {
- return isNaN(Number(this._min.text)) ? this.minIn : NumberUtil.constrain(Number(this._min.text),this.minIn,this.maxIn);
- }
-
- private function toggleInputs(s:Boolean) : void
- {
- var input:TextInput = s ? this._min : this._max;
- input.visible = !input.visible;
- input.enabled = input.visible;
- }
-
- public function toggleMin() : void
- {
- this.toggleInputs(true);
- }
-
- public function set min(n:Number) : void
- {
- this._min.text = String(n);
- }
-
- public function get max() : Number
- {
- return isNaN(Number(this._max.text)) ? this.minIn : NumberUtil.constrain(Number(this._max.text),this.minIn,this.maxIn);
- }
-
- public function toggleMax() : void
- {
- this.toggleInputs(false);
- }
-
- private function validInput(input:TextInput) : Boolean
- {
- return !this.validRE.test(input.text);
- }
-
- internal function __setProp__active_ThresholdInputs_Layer1_0() : *
- {
- try
- {
- this._active["componentInspectorSetting"] = true;
- }
- catch(e:Error)
- {
- }
- this._active.enabled = true;
- this._active.label = "";
- this._active.labelPlacement = "right";
- this._active.selected = false;
- this._active.visible = true;
- try
- {
- this._active["componentInspectorSetting"] = false;
- }
- catch(e:Error)
- {
- }
- }
- }
- }
-
-