The NumericStepper component in Flash 8 seems to have a problem. Where
minimum = 1, maximum = 10, stepSize = 2, value = 1, the second value on
clicking the up arrow is 2. Then it is changing to 4 > 6 > 8 > 10.  What
I expect is 1 > 3 > 5 > 7 > 9 > 10.

Therefore, I modified NumericStepper.checkValidValue() method as
follows.  To test the script just place the NumericStepper component
into the [Library] without anything on the stage.

Any comments and suggestions for this modification would be very
appreciated.

// dynamically placing a NumericStepper instance
import mx.managers.DepthManager;
import mx.controls.NumericStepper;
var myNumericStepper:NumericStepper =
this.createClassChildAtDepth(NumericStepper, DepthManager.kTop);
// initializing
myNumericStepper.move(10, 10);
myNumericStepper.minimum = 1;
myNumericStepper.maximum = 10;
myNumericStepper.stepSize = 2;
myNumericStepper.value = myNumericStepper.minimum;
// modifying NumericStepper.checkValidValue() method
NumericStepper.prototype.checkValidValue = function(val:Number):Number  {
        // var initDiv:Number = val/this.stepSize;
        // var roundD:Number = Math.floor(initDiv);
        var stepS:Number = this.stepSize;
        var minVal:Number = this.minimum;
        var maxVal:Number = this.maximum;
        var initDiv:Number = (val-minVal)/this.stepSize+minVal;
        var roundD:Number = Math.floor(initDiv-minVal)+minVal;
        // if (val>minVal and val<maxVal) {
        if (val>minVal && val<maxVal) {
                if (initDiv-roundD == 0) {
                        return val;
                } else {
                        // var tmpV:Number = Math.floor(val/stepS);
                        var tmpV:Number = Math.floor((val-minVal)/stepS);
                        var stepDownV:Number = tmpV*stepS+minVal;
                        if ((val-stepDownV>=stepS/2 && maxVal>=stepDownV+stepS 
&&
minVal<=stepDownV-stepS) || (val+stepS == maxVal &&
maxVal-stepDownV-stepS>0.00000000000001)) {
                                stepDownV += stepS;
                        }
                        return stepDownV;
                }
        } else {
                if (val>=maxVal) {
                        return maxVal;
                } else {
                        return minVal;
                }
        }
};

-- 
Fumio Nonaka
mailto:[EMAIL PROTECTED]
http://www.FumioNonaka.com/
My books<http://www.FumioNonaka.com/Books/index.html>
Flash community<http://F-site.org/>

_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to