Dynamic sliders numero 2

Title: Dynamic Sliders Numero 2

After working with the previous version of the sliders -se previous post-. I had the opportunity to “upgrade” the sliders since there was a slight chance that the sliders had to react to only one button rather than two as originally planned. Needless to say it wasn’t required to apply this update but it came out nice. Once again there was no need to update anything in the class but just 2 extra lines of code.

[kml_flashembed movie=”/labs/swf/slider2.swf” height=”250″ width=”300″ /]

Dynamic Sliders

So I was working on a project where we needed some sliders, it was basically the same slider but in different sizes and positions. So today I was sitting there just wondering how I could make this more dynamic, and just put a small class together and created a small sample. Updating the sliders the way they were originally created took a long time but allowing the sliders take the parameters dynamically it took seconds to update.

Here is the sample and feel free to play with it 🙂

[kml_flashembed movie=”/labs/swf/slider.swf” height=”250″ width=”300″ /]

Actionscript Round and keep decimals function

[as]function formatDecimals2 (num, digits) {

if (num < 0 ) { num = 0; } if (digits <= 0) { return Math.round(num); } var tenToPower = Math.pow(10, digits); var cropped = String(Math.round(num * tenToPower) / tenToPower); trace("digits:" + digits + " - " + cropped); } formatDecimals2( 35435.234234, 2); formatDecimals2( 35435.234234, 3); formatDecimals2( 35435.234234, 4);[/as]