Using the Jewel Slider Control

In this example we'll see the basic use of the Jewel Slider control in a Royale application. It uses the new Jewel UI set that supports themes and is available in the 0.9.4 release or later.

<?xml version="1.0" encoding="UTF-8"?>
<j:Application xmlns:fx=""
        private function clickHandler(event:MouseEvent):void
            slider_w.value = 400;
            slider_h.value = 200;

        private function onValueChange(event:Event):void
            button.width = slider_w.value;
            button.height = slider_h.value;
            button.text = slider_w.value + "x" + slider_h.value;

                <j:VerticalLayout gap="10"/>

            <j:Slider id="slider_w" width="250" value="250" minimum="100" maximum="500"

            <j:Slider id="slider_h" width="250" value="80" minimum="40" maximum="300"

            <j:Button id="button" text="Slider to 400x200" width="250" height="80" emphasis="secondary"

In this example, you can click the Jewel button to set up slider values. When you do this the ValueChangeEvent.VALUE_CHANGE will fire, calling the onValueChange event handler and setting width, height and text in the Button.

On the other hand, you can drag each slider to change width and height in the Button, and function to update value in "onValueChange" will be called continuously as you drag the slider controls.

You can click in the track at any place to change the value immediately to the value at that point in the track. And if you need them, you have available "input" and "change" events in Slider. The first fires each time you move the slider thumb from one position to another, and the second fires when Slider ends its change from one position to another.

Where to go from here

The result of this code snippet is the following:

(We're using an iframe to host the actual results of this example compilation. To see the example in a separate window click this link.)

Full project with source code can be found here:

Project Source Code