PageRenderTime 61ms CodeModel.GetById 34ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

/src/com/bit101/components/HUISlider.as

https://bitbucket.org/HopeSky/mars_nd2d
ActionScript | 97 lines | 30 code | 14 blank | 53 comment | 0 complexity | e2dfb2b8cbae6514f7abdaf2b970c73b MD5 | raw file
 1/**
 2 * HUISlider.as
 3 * Keith Peters
 4 * version 0.9.2
 5 * 
 6 * A Horizontal slider with a label and a value label.
 7 * 
 8 * Copyright (c) 2010 Keith Peters
 9 * 
10 * Permission is hereby granted, free of charge, to any person obtaining a copy
11 * of this software and associated documentation files (the "Software"), to deal
12 * in the Software without restriction, including without limitation the rights
13 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 * copies of the Software, and to permit persons to whom the Software is
15 * furnished to do so, subject to the following conditions:
16 * 
17 * The above copyright notice and this permission notice shall be included in
18 * all copies or substantial portions of the Software.
19 * 
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26 * THE SOFTWARE.
27 */
28 
29package com.bit101.components
30{
31	import flash.display.DisplayObjectContainer;
32	import flash.events.Event;
33
34	public class HUISlider extends UISlider
35	{
36		
37		/**
38		 * Constructor
39		 * @param parent The parent DisplayObjectContainer on which to add this HUISlider.
40		 * @param xpos The x position to place this component.
41		 * @param ypos The y position to place this component.
42		 * @param label The string to use as the label for this component.
43		 * @param defaultHandler The event handling function to handle the default event for this component.
44		 */
45		public function HUISlider(parent:DisplayObjectContainer = null, x:Number = 0, y:Number = 0, label:String = "", defaultEventHandler:Function = null)
46		{
47			_sliderClass = HSlider;
48			super(parent, x, y, label, defaultEventHandler);
49		}
50		
51		/**
52		 * Initializes the component.
53		 */
54		override protected function init():void
55		{
56			super.init();
57			setSize(200, 18);
58		}
59		
60		/**
61		 * Centers the label when label text is changed.
62		 */
63		override protected function positionLabel():void
64		{
65			_valueLabel.x = _slider.x + _slider.width + 5;
66		}
67		
68		
69		
70		
71		///////////////////////////////////
72		// public methods
73		///////////////////////////////////
74		
75		/**
76		 * Draws the visual ui of this component.
77		 */
78		override public function draw():void
79		{
80			super.draw();
81			_slider.x = _label.width + 5;
82			_slider.y = height / 2 - _slider.height / 2;
83			_slider.width = width - _label.width - 50 - 10;
84			
85			_valueLabel.x = _slider.x + _slider.width + 5;
86		}
87		
88		///////////////////////////////////
89		// event handlers
90		///////////////////////////////////
91		
92		///////////////////////////////////
93		// getter/setters
94		///////////////////////////////////
95		
96	}
97}