| 首页 | 新闻 | 网页 | 设计 | 色彩 | 原创 | 视觉 | 素材 | 动漫 | 酷站 | 策划 | 文案 | 访谈 | 运营 | 编程 | 数据库 | 服务器 | 下载 | 图库 | 
您的位置: 幽幽天空 > 网页 > 网页制作 > Flash教程 > ActionScript教程 > 文章正文 用户登录
免费在线代理服务
免费流量统计计数
一个很实用的基于
flash事件模型核心
如何开发基于ASP的
FlashCom 连接器
简介动画制作过程
在List组件中使用
AS计算方面的错误
如何用flash做除法

计算器           

计算器

作者:佚名 来源:闪吧 作者: 踏步惊云 更新:2007-1-13 20:46:03 错误报告 我要投稿
   点击浏览该文件

代码贴出来,省得大家去下载原文件!
帧上的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"

同上.

文章录入:skyuu    责任编辑:skyuu 
  • 上一篇文章:

  • 下一篇文章:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    发表评论:
    姓名:  评 分: 1分 2分 3分 4分 5分
     
  • 严禁发表危害国家安全、政治、黄色淫秽等内容的评论。
  • 用户需对自己在使用幽幽天空服务过程中的行为承担法律责任。
  • 本站管理员有权保留或删除评论内容。
  • 评论内容只代表机友个人观点,与本网站立场无关。