动画演示效果:
码贴出来,省得大家去下载原文件!
帧上的AS:
display = "0";
stop();
function getdigit(digit) {
if(clear){
clear = false;
decimal = false;
display = "0";
}
if(length(display)<13){
if(display == "0" and digit != "."){
display = digit;
} else {
display = display+digit;
}
}
}
function getoperator(sign){
if(operator == "+") {
display = Number(operand)+Number(display);
symbol = operator;
}
if(operator == "-") {
display = operand-display;
symbol = operator;
}
if(operator == "*") {
display = operand*display;
symbol = "x";
}
if(operator == "/") {
display = operand/display;
symbol = operator;
}
operator = "=";
clear = true;
symbol = " ";
decimal = "false";
if(sign != null){
operator = sign;
if(operator == "*"){
symbol = "x";
} else { symbol = operator;}
operand = display;
}
}
按钮上的:
"1"
on(release,keyPress"1"){getdigit("1")}
"2"
on(release,keyPress"2"){getdigit("2")}
"3","4","5",......,"0"同上!
"+"
on(release,keyPress"+"){getoperator("+")}
"-"
on(release,keyPress"-"){getoperator("-")}
"X","/"同上.
"M+"
on(release){
memory = memory+Number(display);
symbol = "";
mem = "M+";
}
"MR"
on(release){display = memory;}
"MC"
on(release){
memory = 0; mem = " "; display = "0";
operator = ""; operand = false; clear = false;
decimal = false;
}
"C"
同上.