qnx.ui.slider.Slider

Slider

Properties | Methods | Events | Examples


Packageqnx.ui.slider
Classpublic class Slider
InheritanceSlider Inheritance UIComponent Inheritance flash.display.MovieClip
Subclasses ToggleSwitch, VolumeSlider

The 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:

A slider component.

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 );
     }
     


Class information:
PlayBook Tablet OS Version:   1.0.6

View the examples

See also

VolumeSlider



Public Properties

 PropertyDefined By
  active : Boolean
Gets or sets the active property of the Slider.
Slider
 Inheritedcontainment : 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
 Inheritedsize : Number
Gets or sets the size for this component (as a percentage of the container's size, or in pixels).
UIComponent
 InheritedsizeMode : String
Gets or sets the size mode for this component.
UIComponent
 InheritedsizeUnit : 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

Public Methods

 MethodDefined By
  
Creates a new Slider instance.
Slider
 Inherited
destroy():void
Call this method when you want to have your object collected by the garbage collector.
UIComponent
 Inherited
drawNow():void
Calls the draw() method.
UIComponent
 Inherited
invalidate(property:String = all, 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
 Inherited
setPosition(x:Number, y:Number):void
Sets the x and y position of the component.
UIComponent
 Inherited
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

Protected Methods

 MethodDefined By
 Inherited
callLater(method:Function):void
Calls the specified method on the next frame or the next render, which ever happens first.
UIComponent
 Inherited
createInstance(linkage:Object):DisplayObject
Calling this method will attempt to create a DisplayObject instance based on the value of the linkage parameter.
UIComponent
 Inherited
draw():void
Called every time you set the width and height of the component.
UIComponent
 Inherited
isInvalid(property:String, ... properties):Boolean
Checks to see if the property is invalid and returns true if it is.
UIComponent
 Inherited
onAdded():void
Called when the instance is added to the stage.
UIComponent
 Inherited
onRemoved():void
Called when the instance is removed from the stage.
UIComponent
 Inherited
setEnabled(val:Boolean):void
Called when the enabled property changes.
UIComponent
 Inherited
validate(property:String = all):void
Lets the component know that the specified property has been validated.
UIComponent

Events

 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

Property Detail

active


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.


Implementation

public function get active():Boolean
public function set active(value:Boolean):void

maximum


maximum:Number

Gets or sets the maximum value of the slider.

The maximum value represents the very right extent of the track.

The default value is 100.


Implementation

public function get maximum():Number
public function set maximum(value:Number):void

minimum


minimum:Number

Gets or sets the minimum value of the slider.

The minimum value represents the very left extent of the track.

The default value is 0.


Implementation

public function get minimum():Number
public function set minimum(value:Number):void

value


value:Number

Gets 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.


Implementation

public function get value():Number
public function set value(value:Number):void

Constructor Detail

Slider()


public function Slider()

Creates a new Slider instance.

Method Detail

setFillSkin()


public function setFillSkin(skin:Object):void

Sets 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()


public function setThumbSkin(skin:Object):void

Sets 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()


public function setTrackSkin(skin:Object):void

Sets 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.

Event Detail

slider_drag_ended


Event Object Type: qnx.ui.events.SliderEvent
SliderEvent.type property = qnx.ui.events.SliderEvent.END

Dispatched when a drag event ends.

slider_drag_started


Event Object Type: qnx.ui.events.SliderEvent
SliderEvent.type property = qnx.ui.events.SliderEvent.START

Dispatched when a drag event starts.

slider_move


Event Object Type: qnx.ui.events.SliderEvent
SliderEvent.type property = qnx.ui.events.SliderEvent.MOVE

Dispatched when the slider is moved by the user.

Examples

The following example creates a simple 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 );
        }
        
    
    }
}