FlashAS创作:计算器

王朝other·作者佚名  2008-05-19
窄屏简体版  字體: |||超大  

动画演示效果:

码贴出来,省得大家去下载原文件!

帧上的AS:

display="0";

stop();

functiongetdigit(digit){

if(clear){

clear=false;

decimal=false;

display="0";

}

if(length(display)<13){

if(display=="0"anddigit!="."){

display=digit;

}else{

display=display+digit;

}

}

}

functiongetoperator(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"

同上.

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航