| Package | qnx.ui.slider |
| Class | public class Slider |
| Inheritance | Slider UIComponent flash.display.MovieClip |
| Subclasses | ToggleSwitch, VolumeSlider |
Slider class contains the functionality for a basic Slider implementation. The slider component allows a user to select
a value (by dragging the thumb component along a track) between the specified minimum and
maximum values:
The following example instantiates and initializes a new slider component called mySlider:
mySlider = new Slider();
mySlider.setPosition(300, 300);
mySlider.minimum = 0;
mySlider.maximum = 100;
mySlider.value = 50;
mySlider.width = 250;
// listen to the when the slider moves
mySlider.addEventListener( SliderEvent.MOVE, sliderChange );
this.addChild( mySlider );
The horizontal slider has a minimum value of 0, and a maximum value of 1000. The following function, which is called by the event listener updates the value (level) of the slider every time the user moves the slider thumb:
private function sliderChange( event:SliderEvent ) : void
{
var newlevel:int = Math.round( slider.value );
trace( "slider value =", newlevel );
}
See also
| Property | Defined By | ||
|---|---|---|---|
| active : Boolean
Gets or sets the active property of the Slider. | Slider | ||
![]() | containment : String
Gets or sets a property that determines how a component is contained within a parent container. | UIComponent | |
| maximum : Number
Gets or sets the maximum value of the slider. | Slider | ||
| minimum : Number
Gets or sets the minimum value of the slider. | Slider | ||
![]() | size : Number
Gets or sets the size for this component (as a percentage of the
container's size, or in pixels). | UIComponent | |
![]() | sizeMode : String
Gets or sets the size mode for this component. | UIComponent | |
![]() | sizeUnit : String
Gets or sets the unit of measure for the size property. | UIComponent | |
| value : Number
Gets or sets the current value of the slider. | Slider | ||
| Method | Defined By | ||
|---|---|---|---|
Slider()
Creates a new Slider instance. | Slider | ||
![]() | destroy():void
Call this method when you want to have your object collected by the garbage collector. | UIComponent | |
![]() | drawNow():void
Calls the draw() method. | UIComponent | |
![]() | invalidate(property:String, invalidateNow:Boolean = false):void
Marks the property as invalid and the draw() method is called on the next frame or the next render, whichever comes first. | UIComponent | |
setFillSkin(skin:Object):void
Sets the fill skin for the slider. | Slider | ||
![]() | setPosition(x:Number, y:Number):void
Sets the x and y position of the component. | UIComponent | |
![]() | setSize(w:Number, h:Number):void
Sets the width and height of the component. | UIComponent | |
setThumbSkin(skin:Object):void
Sets the skin for the slider thumb button. | Slider | ||
setTrackSkin(skin:Object):void
Sets the skin for the track of the slider. | Slider | ||
| Event | Summary | Defined By | ||
|---|---|---|---|---|
| Dispatched when a drag event ends. | Slider | |||
| Dispatched when a drag event starts. | Slider | |||
| Dispatched when the slider is moved by the user. | Slider | |||
| active | property |
active:Boolean
Gets or sets the active property of the Slider.
The active property is used to determine whether or not the user can interact with the
slider. If set to false, the thumb is disabled and the slider can only be used for display purposes:
The default value is true.
public function get active():Boolean public function set active(value:Boolean):void| maximum | property |
maximum:NumberGets or sets the maximum value of the slider.
The maximum value represents the very right extent of the track.
The default value is 100.
public function get maximum():Number public function set maximum(value:Number):void| minimum | property |
minimum:NumberGets or sets the minimum value of the slider.
The minimum value represents the very left extent of the track.
The default value is 0.
public function get minimum():Number public function set minimum(value:Number):void| value | property |
value:NumberGets or sets the current value of the slider. The value is represented by the position of the thumb on the slider track.
Setting this property will cause the thumb to update its position. This value is updated as the user drags the slider thumb.
The value is constrained to be within the minimum and maximum values.
The default value is 0.
public function get value():Number public function set value(value:Number):void| Slider | () | Constructor |
public function Slider()Creates a new Slider instance.
| setFillSkin | () | method |
public function setFillSkin(skin:Object):voidSets the fill skin for the slider. The fill skin is the area of the track to the left of the slider thumb button (in a horizontal slider) that represents the current value of the slider.
You can pass in a qualified class name String, or the actual class.
In either instance the class that is used must implement the ISkin interface.
Note: Do not pass in an instance of a skin class. This may cause unexpected behavior.
Parameters
skin:Object — The fill skin to set.
|
| setThumbSkin | () | method |
public function setThumbSkin(skin:Object):voidSets the skin for the slider thumb button. The thumb is the button that the user moves along the track to change the value of the slider.
You can pass in a qualified class name String, or the actual class.
In either instance the class that is used must implement the ISkin interface.
Note: Do not pass in an instance of a skin class. This may cause unexpected behavior.
Parameters
skin:Object — The button skin to set.
|
| setTrackSkin | () | method |
public function setTrackSkin(skin:Object):voidSets the skin for the track of the slider. The track is the vertical or horizontal line that the thumb button moves along.
You can pass in a qualified class name String, or the actual class.
In either instance the class that is used must implement the ISkin interface.
Note: Do not pass in an instance of a skin class. This may cause unexpected behavior.
Parameters
skin:Object — The track skin to set.
|
| slider_drag_ended | Event |
qnx.ui.events.SliderEventqnx.ui.events.SliderEvent.ENDDispatched when a drag event ends.
| slider_drag_started | Event |
qnx.ui.events.SliderEventqnx.ui.events.SliderEvent.STARTDispatched when a drag event starts.
| slider_move | Event |
qnx.ui.events.SliderEventqnx.ui.events.SliderEvent.MOVEDispatched when the slider is moved by the user.
Slider instance and adds it to the stage.
package
{
import flash.display.Sprite;
import qnx.ui.events.SliderEvent;
import qnx.ui.slider.Slider;
[SWF(height="600", width="1024", frameRate="30",
backgroundColor="#FFFFFF")]
public class sliderSample extends Sprite
{
private var mySlider:Slider;
public function sliderSample()
{
initializeUI();
}
private function initializeUI():void
{
mySlider = new Slider();
mySlider.setPosition(300, 300);
mySlider.minimum = 0;
mySlider.maximum = 100;
mySlider.value = 50;
mySlider.width = 250;
// listen to the when the slider moves
mySlider.addEventListener( SliderEvent.MOVE, sliderChange );
this.addChild( mySlider );
}
private function sliderChange( event:SliderEvent ) : void
{
var newlevel:int = Math.round( event.target.value );
trace( "slider value: ", newlevel );
}
}
}