txtDisplay.text = num1+expression+num2;

FYI: This is a calculator.

I am trying to figure out how to do it in this very method and nothing else. (Please do not suggest if statements or case statements. Thanks)

Example
when someone clicks on button 1, num1=1;
then they will click on the +,-,* or / button
so expression variable will be set to = “/” or “+” or “-” or “*”
then they would choose the next integer.
lets say button 2, num2=2

so now we have values for num1,expression,num2

I have already parseInt num1 and num2

i want txtDisplay.text = num1+expression+num2;

But it is showing up on the textbox as 1+2; //if add was chosen

I hope I am making myself clear

whats the code on button1?

Welcome, jigsaw. :slight_smile:

How about something like this?

var equations = new Object();
equations["+"] = function (a, b) {
	return a+b;
};
equations["-"] = function (a, b) {
	return a-b;
};
equations["*"] = function (a, b) {
	return a*b;
};
equations["/"] = function (a, b) {
	return a/b;
};
var e = "*";
var n1 = 2;
var n2 = 2;
var r = equations[e](n1, n2);
trace(r);

…I honestly don’t think there’s another way, since you don’t want to use [font=courier new]if[/font] or [font=courier new]switch[/font] statements. :-/