My Slider Component

I just put together a component for my personal use and thought maybe others might want to use it. It’s a slider bar thingy that I use for debugging and development (it is not intended to be left in the project during publishing…it is just a debugging tool, hence it don’t look that great).

Here’s how I use it:
I put an instance of it on the stage, name ths instance (for example “sliderThingy”), then define 3 properties which are:

The value the slider outputs when it is at the far left. (Defaults to 0)

The value the slider outputs when it is at the far right. (Defaults to 100)

The number of decimal places the slider’s output is rounded to. (Default 0)

Then, in my actionscript I call the slider’s getOutput() method to find out what the slider is showing. So for example, if I want to get the output every frame I might put this in an onEnterFrame block: myVariable = _root.sliderThingy.getOutput();

That’s it. You can slide the bar with the mouse, or you can enter a number into the text field.

I use this for testing out things like different constants for focalLength in my 3D engines, gravity constants in physics simulations, etc.

It has no documentation other than what you have read above cause it’s really just for my use. If people find it useful I might throw together some docs for it.

If you DO find it useful, please let me know. Also, please report any bugs and I am open to comments/suggestions/questions of course!

-Al

Nice :slight_smile:

Cleaned it up slightly and fixed a minor bug.

-Al

Hi Al,

This is nice and works very well except for a problem that I’ve found.

If you extend the end value to anything greater than 100 you can no longer slide the slider to the very end.

In your first version of this I fixed it by subtracting 1 from the groove width prior to the multiplication in calcValue.

In your latest I had to subtract 1.8 from it (it seems to set the width to longer than what’s in the property sheet window).

I changed it in the end to have a new variable at the class level gWidth which I set in the init function.

I will attach the changed fla so you can take a look at what I’ve done.

Liz

Thanks for the fix, Liz!

Hi again,

Here’s the latest with a change to allow actionscript to set the value in the text box and have it correctly reflected on the scrollbar.

Liz