Constructors

Properties

Methods

SliderUI class

SliderUI

extends EventDispatcher

 

 

Overview

Author

Matt Przybylski [http://www.reintroducing.com]

Version

1.51

Description

The SliderUI is a class that allows you to quickly create sliders with tracks without the need to use components. There is a "percent" and a "currentValue" property that you can tap into to see what position the slider is at on the track. The SliderUI dispatches a couple of custom events that also contain these values as well as the slider and track display objects.
  • SliderUIEvent.ON_PRESS - Dispatched when the slider is pressed
  • SliderUIEvent.ON_RELEASE - Dispatched when the slider is released
  • SliderUIEvent.ON_UPDATE - Dispatched while the slider is dragged
  • SliderUIEvent.ON_ENABLED - Dispatched when the slider is enabled
  • SliderUIEvent.ON_DISABLED - Dispatched when the slider is disabled
Please note that if you are using the SliderUI on the "y" axis your track's registration point needs to be on the bottom (NOT the top) and the slider will go up to raise the value and down to lower it. If you do not pay attention to this your slider will be "broken".

Constructors

 

SliderUI

Usage

public function SliderUI($stage:Stage, $axis:String, $track:Sprite, $slider:Sprite, $lowVal:Number, $highVal:Number, $startVal:Number = 0, $precision:int = 0):void

Description

Creates an instance of the SliderUI with the given parameters. If the $startVal parameter is set to something higher than the $highVal or lower than the $lowVal parameter, the $startVal parameter is reset to one of those two values. If you do not set the $precision parameter, your current value will be rounded to the nearest whole number and the slider will snap into place at the appropriate position on the track.

Parameters

$stage
The stage that the track and slider are sitting on
$axis
The axis that the slider will be used on
$track
The track to be used for the slider
$slider
The object that will function as the slider
$lowVal
A number representing the low value of the slider
$highVal
A number representing the high value of the slider
$startVal
A number representing the value the slider should start at (default: 0)
$precision
An integer representing the number of decimal places to round the current value to (default: 0)

Properties

 

percent

Usage

public function get percent():Number

Description

Returns the percentage of the slider's position on the track, between 0 and 1.Sets the slider's percentage according to the one provided and physically moves it to the corresponding position on the track.
 

currentValue

Usage

public function get currentValue():Number

Description

Returns the current value of the slider's position on the track.Sets the slider's current value according to the one provided and physically moves it to the corresponding position on the track.

Methods

 

enable

Usage

public function enable():void

Description

Enables the controls of the SliderUI.

Returns

void
 

disable

Usage

public function disable():void

Description

Disables the controls of the SliderUI.

Returns

void
 

destroy

Usage

public function destroy():void

Description

Cleans up the SliderUI for garbage collection.

Returns

void