# Calaulator Script

**URL:** <https://forum.kirupa.com/t/calaulator-script/181280>\
**Category:** flash\
**Created:** [March 8, 2006, 1:36am UTC](https://forum.kirupa.com/t/calaulator-script/181280 "2006-03-08T01:36:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![inukai](https://avatars.discourse-cdn.com/v4/letter/i/73ab20/32.png) [@inukai](https://forum.kirupa.com/u/inukai)\
**Post date:** [March 8, 2006, 1:36am UTC](https://forum.kirupa.com/t/calaulator-script/181280/1 "2006-03-08T01:36:50Z")

</div>

This is probably simple, but are there any conflicts with these scripts I’ve made for calculator buttons (The buttons will be named ‘1’ ‘2’ ‘3’ ‘Plus’ ‘Minus’ ‘Equals’ etc.)

Frame 1

currentNumb = 0 //Number being added, subtracted, etc from  
secondNumb = 0 //Modifying number  
totalNumb = 0 //Number displayed on calculator  
arithFunction = 0 //Says which arithmitic operation to use (0= None, 1=Add, 2=Subtract, 3=Multiply, 4=Divide)

Frame 2  
stop();  
\_root.Number == totalNumb //Tells the Dynamic text ‘Number’ to display the nuber)

Button X (X = 1, 2, 3…)

on(press) {if (currentNumb == 0){ //Tells whether to add number to currentNumb or secondNumb  
currentNumb = X  
totalNumb = X  
} else {  
secondNumb = X  
totalNumb = X  
}  
}

Aritmitic Button (Add, Subtract, etc.) Y = What button you pressed

on(press){  
arithFunction = Y  
}

Equals button (A = + or - or \* or / depending on the arithFunction variable

on(press){  
if (arithFunction = Y){  
totalNumb = currentNumb secondNumb  
}
