In this Tutorial, I will teach you how to create a basic flash calculator with simple Actionscript. This tutorial is very simple and easy to understand, this is to ensure that newbie can follow.
Steps On Creating Flash Calculator Using Actionscript
Step 1: Create 2 Input Text
On frame 1, create this 2 input text, which is for user to key in their value, and then set the var to val1 and val2 respectively.

Step 2: Create 1 Dynamic Text
Same as 1st step, on the first frame, create 1 dynamic text, which is for displaying result. Set the var to output.
Step 3: Create An Empty Movie Clip
This is to make your calculator more sophisticated, you just add a empty movie clip which will show recently performed action by showing it symbol between the two values. Then, named it as “action“.
Then, click on the empty movie clip, leave the first frame as blank and then insert 5 keyframes, create basic arithmetic symbol on each frame and click on the each keyframe and label it accordingly. And, you need to give it a stop for each frame, just press F9 for each frame, insert the stop();
Step 4: Create 4 Operators (+ – x /) and Reset Button
On the first frame, create 4 operators, which is the options for user to choose for the operation. You might create it using 4 static text and put + – x / into it respectively or you can use image to represent each operator sign.
After that, right click on the it, and choose Convert to Symbol, then give the appropriate name for each, for my case, I give the name of + as plus, – as minus, x as multiply, / as divide and reset as reset. Then, set each behavior as Button.
Next, you can insert this code into each button. You need to select the button and then press F9 to insert your Actionscript. Just follow my steps below:
For Plus Operator:
on (release) {
// If you use the simple plus code, it is a concatenate and it wont work, so i use the Number function as follows.
output = Number(val1) + Number( val2);
}
on (release) {
//use tellTarget to control actions and animations in another nested movie
tellTarget (”action“) {
//use gotoAndStop to tell the Flash go directly to a specific frame and stop
gotoAndStop(”plus“);
}
}
For Minus Operator:
output = val1 – val2;
}
on (release) {
tellTarget (”action“) {
gotoAndStop(”minus“);
}
}
For Multiply Operator:
output = val1 * val2;
}
on (release) {
tellTarget (”action“) {
gotoAndStop(”multiply“);
}
}
For Divide Operator:
output = val1 / val2;
}
on (release) {
tellTarget (”action“) {
gotoAndStop(”divide“);
}
}
For Reset Button:
This is to clear button’s action:
output = 0;
val1 = 0;
val2 = 0;
}
on (release) {
tellTarget (”action“) {
gotoAndStop(”blank“);
}
}
Congratulations! Test your calculator!




By How I Make $300 a Day Online on Jun 18, 2009 | Reply
Hey, great post, really well written. You should post more about this.
By KonstantinMiller on Jul 7, 2009 | Reply
Hi. I like the way you write. Will you post some more articles?
By Mohanraj on Jul 28, 2009 | Reply
Sir,
Welcome, I am interest in action script,
but i am basically 3ds max working in architect
thank you for your tutorial