Java Reference
In-Depth Information
Listing 12.23
SliderSkin - calcValue()
function calcValue(per:Number) : Number {
var val = per * range + slider.minimum;
if(slider.snapTo != 0.0) {
val += slider.snapTo/2.0;
var rem =
Math.IEEEremainder(val, slider.snapTo);
val = val-rem;
}
val;
}
An example of using a slider is in Listing 12.24. The value is bound to a local
variable called lvalue . This must be bound with inverse as a change to lvalue
will be reflected on the slider, and if the user changes the slider value , this will
in turn be reflected in lvalue . Failure to use the with inverse bind will result
in an exception.
Listing 12.24
Slider Usage
var scene:Scene;
var lvalue :Number = 50 on replace {
println(value);
};
Stage {
title: "Slider"
width: 300
height: 80
scene: scene = Scene {
content: Slider {
translateY: 10
translateX: 10
height: 50
snapTo: 0.5
value: bind lvalue with inverse
width: bind scene.width-20
}
}
}
Figure 12.10 shows what the Slider looks like. Also, remember that because
Slider is a control, you can use cascading style sheets to control its appearance.
This includes the colors, knob size, and fonts. For more information on using
cascading style sheets, see Chapter 5.
 
Search WWH ::




Custom Search