you could use repeater component with numericsteppers
as children and a text box for the sum instead. But i
guess what you need is something more straightforward
and simple like this:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application creationComplete="init()"
xmlns:mx="http://www.adobe.com/2006/mxml";
layout="absolute">
<mx:Script>
        <![CDATA[
                
                [Bindable] private var total:uint = 0;
                                
                //set max value to maximum value of uint; change
value as required
                private var maxvalue:uint = uint.MAX_VALUE;
                
                //determines remaining increments available,
initially equal to max value
                private var remaining:uint = uint.MAX_VALUE;
                
                
                private function init():void{
                        n1.maximum = maxvalue;
                        n2.maximum = maxvalue;
                        n3.maximum = maxvalue;
                        n4.maximum = maxvalue;
                        n5.maximum = maxvalue;
                        n6.maximum = maxvalue;
                }
                
                private function updateValues(e:Event):void{
                        
                        total = n1.value + n2.value + n3.value + n4.value +
n5.value;
                        remaining = maxvalue - total;
                                                
                        updateMaxValues();
                        
                }
                
                private function updateMaxValues():void{
                        n1.maximum = remaining + n1.value;
                        n2.maximum = remaining + n2.value;
                        n3.maximum = remaining + n3.value;
                        n4.maximum = remaining + n4.value;
                        n5.maximum = remaining + n5.value;
                }
                
                
        ]]>
</mx:Script>
        <mx:VBox>
                <mx:NumericStepper id="n1" 
change="updateValues(event)"/>
                <mx:NumericStepper id="n2" 
change="updateValues(event)"/>
                <mx:NumericStepper id="n3" 
change="updateValues(event)"/>
                <mx:NumericStepper id="n4" 
change="updateValues(event)"/>
                <mx:NumericStepper id="n5" 
change="updateValues(event)"/>
                <mx:NumericStepper id="n6" value="{total}"
mouseChildren="false"/>
        </mx:VBox>
</mx:Application>


This code initially sets the maximum value for all the
steppers to uint.MAX_VALUE (4294967295) - but i guess
you may want to change that accordingly. I have
intentionally disabled mouseclicks on the "total"
stepper (like I said you could use a text box instead
- unless you really need to be able to increment the
total stepper manually as well). Upon testing, you'll
see that when max value for total is reached, you will
not be able to increment the steppers unless you
decrement one of them  - in which case, 1 increment
will be allowed and so on and so fort.

Hoe this helps :) Cheers!



--- JRBower <[EMAIL PROTECTED]> wrote:

> 
> Can someone help?
> 
> I have 5 numericsteppers and I would like to be able
> to display their total
> in a sixth NumericStepper. 
> 
> ns01 + ns02 + ns03 + ns04 + ns05 = nsTotal06
> 
> How can I do this?
> 
> Thanks,
> 
> James
> 
> -- 
> View this message in context:
>
http://www.nabble.com/Adding-several-NumericSteppers-%3D-Total-tp14750764p14769497.html
> Sent from the FlexCoders mailing list archive at
> Nabble.com.
> 
> 



      
____________________________________________________________________________________
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  
http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ 

Reply via email to