qnx.fuse.ui.slider.Slider

Slider

Properties | Methods | Events | Examples


Packageqnx.fuse.ui.slider
Classpublic class Slider
InheritanceSlider Inheritance SliderBase Inheritance UIComponent Inheritance flash.display.MovieClip
Subclasses 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 100. 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 a value that determines whether the control is active and enabled.
Slider
 InheritedexplicitHeight : Number
[read-only] Returns the explicit height (actual height, in pixels) of the UI component.
UIComponent
 InheritedexplicitWidth : Number
[read-only] Returns the explicit width (actual width, in pixels) of the UI component.
UIComponent
 InheritedincludeInLayout : Boolean
Specifies whether or not the component should be included in its parent container's layout.
UIComponent
 InheritedlayoutData : Object
Returns the layout data for the object.
UIComponent
  maximum : Number
Gets or sets the maximum value of the slider.
Slider
 InheritedminHeight : Number
Gets or sets the minimum preferred height of the control.
UIComponent
  minimum : Number
Gets or sets the minimum value of the slider.
Slider
 InheritedminWidth : Number
Gets or sets the minimum preferred width of the control.
UIComponent
  value : Number
Gets or sets the current value of the slider.
Slider

Public Methods

 MethodDefined By
  
Creates a new Slider instance.
Slider
 Inherited
childChanged(resizedChild:DisplayObject = null):Boolean
Notifies the UIComponent that one or more of its children has changed in a manner that may affect this object's layout.
UIComponent
 Inherited
destroy():void
Call this method when you want to have your object collected by the garbage collector.
UIComponent
 Inherited
Returns the size options for the given control.
UIComponent
 Inherited
Calling this method results in a call to the components validateDisplayList() method before the display list is rendered.
UIComponent
 Inherited
Calling this method results in a call to the components validateProperties() method before the display list is rendered.
UIComponent
 Inherited
measure(availableWidth:Number, availableHeight:Number):LayoutMeasurement
This method calls doMeasure() in order to calculate the preferred size of the control.
UIComponent
 Inherited
setActualSize(w:Number, h:Number):void
Sets the width and height of the object without setting the explicitWidth and explicitHeight.
UIComponent
 Inherited
setFillSkin(skin:Object):void
Sets the fill skin for the slider.
SliderBase
 Inherited
setLayoutBounds(bounds:Rectangle):void
Sets the receiver's size and location to the rectangular area specified by the arguments.
UIComponent
 Inherited
setPosition(x:Number, y:Number):void
Sets the x and y position of the component.
UIComponent
 Inherited
setThumbSkin(skin:Object):void
Sets the skin for the slider thumb button.
SliderBase
 Inherited
setTrackSkin(skin:Object):void
Sets the skin for the track of the slider.
SliderBase
 Inherited
Validates the display list of the component by calling the updateDisplayList().
UIComponent
 Inherited
Validates the component immediately by calling validateProperties(), validateSizes(), and validateDisplayList() if necessary.
UIComponent
 Inherited
Validates the properties of the component by calling the commitProperties() method.
UIComponent

Protected Methods

 MethodDefined By
 Inherited
Process properties of the component.
UIComponent
 Inherited
Process the state of the component.
UIComponent
 Inherited
createFill(linkage:Object):void
SliderBase
 Inherited
createThumb(linkage:Object):void
SliderBase
 Inherited
createTrack(linkage:Object):void
SliderBase
 Inherited
doMeasure(availableWidth:Number, availableHeight:Number):LayoutMeasurement
[override] Measures the size of the component so that it can be reported to the layout framework for laying the component out properly.
SliderBase
 Inherited
drawFill():void
Draws the fill of the slider.
SliderBase
 Inherited
flushCache():void
Invoked as part of parentLayoutChanged.
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
Invalidates the parent's size and display list if includeInLayout property is set to true.
UIComponent
  
[override] Called when the position of the thumb on the x axis has changed.
Slider
  
[override] Called when the thumb has been pressed by the user.
Slider
  
[override] Called when the thumb has been released by the user.
Slider
  
[override] Called when the thumb has been pressed by the user.
Slider
  
updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
[override] Sets the size and position of the children of the component.
Slider

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 a value that determines whether the control is active and enabled.


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

thumbPositionChanged()


override protected function thumbPositionChanged():void

Called when the position of the thumb on the x axis has changed. Occurs when the user drags the thumb or has clicked on the track. You can override this method if you wish to have elements update themselves based on the value property.

thumbPressed()


override protected function thumbPressed():void

Called when the thumb has been pressed by the user.

You can override this method to perform custom actions when the user presses the thumb.

thumbReleased()


override protected function thumbReleased():void

Called when the thumb has been released by the user.

You can override this method to perform custom actions when the user has released the thumb.

trackPressed()


override protected function trackPressed():void

Called when the thumb has been pressed by the user.

You can override this method to perform custom actions when the user presses the thumb. The default implementation of this method moves the thumb to where the user has pressed and initiates a drag operation.

updateDisplayList()


override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void

Sets the size and position of the children of the component. Component developers will want to subclass this method to adjust its children correctly.

If the component needs to do any drawing it should be done in this method as well.

This method should not be called directly as it is called by framework when its invalidateDisplayList() method is called.

Parameters

unscaledWidth:Number — The unscaled width of the component. Any drawing, sizing and positioning should be based on this value and not width.
unscaledHeight:Number — The unscaled height of the component. Any drawing, sizing, and positioning should be based on this value and not height.

Event Detail

slider_drag_ended


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

Dispatched when a drag event ends.

slider_drag_started


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

Dispatched when a drag event starts.

slider_move


Event Object Type: qnx.fuse.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.fuse.ui.events.SliderEvent;
    import qnx.fuse.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 );
        }
        
        
    }
}