# Button components in MX 2004

**URL:** <https://forum.kirupa.com/t/button-components-in-mx-2004/156594>\
**Category:** Uncategorized\
**Created:** [July 26, 2005, 9:26pm UTC](https://forum.kirupa.com/t/button-components-in-mx-2004/156594 "2005-07-26T21:26:31Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmorin](https://avatars.discourse-cdn.com/v4/letter/j/e99b99/32.png) [@jmorin](https://forum.kirupa.com/u/jmorin)\
**Post date:** [July 26, 2005, 9:26pm UTC](https://forum.kirupa.com/t/button-components-in-mx-2004/156594/1 "2005-07-26T21:26:31Z")

</div>

Well, I 'm not very versed in actionscripting, and since the button component has changed since Flash MX, I don’t understand it.  
I had a project where a button component (in MX) calculated a value when clicked. It’s click handler was onCalculate and on the timeline I had the following code:

```
function onCalculate () {
volume = Number(volume);
current = Number(current);
desired = Number(desired);
doseA = .0019*volume*(desired-current);
doseB = (doseA)*5;
doseA = Math.round(doseA*1000)/1000;
doseB = Math.round(doseB*1000)/1000;

```

}

Now, I don’t know how to do this in MX 2004. The components don’t use click handlers anymore. From reading forums this is the best I could come up with and it is obviously wrong (oh, what I am calculating is diffrent here):

myButtonListener = new Object();  
myButtonListener.click = function onCalculate () {  
width = Number(width);  
depth = Number(depth);  
desired = Number(desired);  
bags = (width_depth_desired)/7000;  
}

```
       myButton.addEventListener("click", myButtonListener);

```

all I want to do is have flash perform this calculation when the button is clicked. It’s probably totally simple, but I don’t know how to do it.

thanks
