views:

51

answers:

1

how do i set up a Flash CS5 Slider component to trace decimal values, from 0.00 to 10.00 when the slider is dragged? i can't seem to find where i need to set these options to permit decimals.

is it possible to set this in ActionScript?

alt text

A: 

perhaps there is a more formal way of accomplishing this, but i've managed to solve this problem by creating a custom string format method.

first, since i want my values to range from 0.00 to 10.00, i set the slider component to have 0 as the minimum value and 1000 as the maximum value. these values will be divided by 100 for the decimal.

//in the slider change event handler method
trace(formatCycleTextString(mySlider.value));

//custom format method
function formatCycleTextString(value:Number):String
    {
    var resultString:String = String(value / 100);

    switch  (resultString.length)
            {
            case 1: resultString = resultString.concat(".00");  break;
            case 2: resultString = resultString.concat(".00");  break;
            case 3: resultString = resultString.concat("0");
            }

    return resultString;
    }
TheDarkInI1978