# Calculating variable values in real time

**URL:** <https://forum.kirupa.com/t/calculating-variable-values-in-real-time/271040>\
**Category:** flash\
**Created:** [September 17, 2008, 5:50pm UTC](https://forum.kirupa.com/t/calculating-variable-values-in-real-time/271040 "2008-09-17T17:50:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![damc\_killer](https://avatars.discourse-cdn.com/v4/letter/d/839c29/32.png) [@damc\_killer](https://forum.kirupa.com/u/damc_killer)\
**Post date:** [September 17, 2008, 5:50pm UTC](https://forum.kirupa.com/t/calculating-variable-values-in-real-time/271040/1 "2008-09-17T17:50:48Z")

</div>

Im probably making this harder that what it is…:crying:

I have an equation that needs to calculate variables as it receives them and output the value to a dynamic text field. I have successfully created a function passed values to it but after the first calculation it wont do anything else.

Here is my code:

//setup my variables to wait for values  
var child1:Number = new Number();  
var child2:Number = new Number();  
var child3:Number = new Number();

onEnterFrame = function(){  
function calcKids(child1, child2, child3) {  
var totalvalue:Number = child1+child2+child3; //calculate all of the children  
number\_output.text = totalvalue; //output to my textfield  
}

//Actions on my button

kid1.onPress = function(){  
calcKids(100,0,0);  
}

kid2.onPress = function(){  
calcKids(0,100,0);  
}

kid3.onPress = function(){  
calcKids(0,0,100);  
}

the totalvalue should read 300 but it stays at 100 .

Any help would be greatly appreciated…
