怎么用Flash脚本做简易计算器。a+b=c。

王小磊爱读书
2011-06-07 · TA获得超过222个赞
知道答主
回答量:91
采纳率:0%
帮助的人:89.7万
展开全部
// Calculator design and powered by tangyan
fscommand("showmenu", false);
//关闭右键菜单
fscommand("allowscale", false);
//播放不进行缩放
fscommand("fullscreen", false);
//不全屏幕显示。前面的几行是对播放器的设置,可以不管他,
//如果有兴趣的话,可以参考金鹰FLASH AS教程
// ***Initializing the variables
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 == "*") {
symbol = "x";
display = operand*display;
}
if (operator == "-") {
symbol = operator;
display = operand-display;
}
if (operator == "/") {
symbol = operator;
display = operand/display;
}
operator = "=";
clear = true;
symbol = " ";
decimal = "false";
if (sign != null) {
operator = sign;
if (operator == "*") {
symbol = "x";
} else {
symbol = operator;
}
operand = display;
}
}
fscommand("showmenu", false);
//关闭右键菜单
fscommand("allowscale", false);
//播放不进行缩放
fscommand("fullscreen", false);
//不全屏幕显示
// ***Initializing the variables
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 == "*") {
symbol = "x";
display = operand*display;
}
if (operator == "-") {
symbol = operator;
display = operand-display;
}
if (operator == "/") {
symbol = operator;
display = operand/display;
}
operator = "=";
clear = true;
symbol = " ";
decimal = "false";
if (sign != null) {
operator = sign;
if (operator == "*") {
symbol = "x";
} else {
symbol = operator;
}
operand = display;
}
}
// Calculator design and made by jinjun
fscommand("showmenu", false);
//关闭右键菜单
fscommand("allowscale", false);
//播放不进行缩放
fscommand("fullscreen", false);
//不全屏幕显示
// ***Initializing the variables
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 == "*") {
symbol = "x";
display = operand*display;
}
if (operator == "-") {
symbol = operator;
display = operand-display;
}
if (operator == "/") {
symbol = operator;
display = operand/display;
}
operator = "=";
clear = true;
symbol = " ";
decimal = "false";
if (sign != null) {
operator = sign;
if (operator == "*") {
symbol = "x";
} else {
symbol = operator;
}
operand = display;
}
}
//到此为止是第一帧的脚本代码

//c:
on (press, keyPress "c") {
display = "0";
operator = "";
symbol = "";
operand = false;
clear = true;
decimal = false;
}
on (press, keyPress "C") {
display = "0";
operator = "";
symbol = "";
operand = false;
clear = true;
decimal = false;
}

//MR
on (release) {
display = memory;
// memory = 0;
// symbol = " ";
// clear = true;
}

//MC
on (release) {
memory = 0;
mem = " ";
display = "0";
operator = "";
operand = false;
clear = false;
decimal = false;
}

//M+
on (release) {
memory = memory+Number(display);
symbol = "";
mem = "M+";
}

//%
on (release, keyPress "%") {
display = display*operand/100;
}

//1
on (release, keyPress "1") {
getdigit("1");
}

//on (release, keyPress "2") {
getdigit("2");
}
//3 4 5 6 7 8 9 0和上面的1 2 相同

//+
on (release, keyPress "+") {
getoperator("+");
}

//-
on (release, keyPress "-") {
getoperator("-");
}

//*
on (release, keyPress "*") {
getoperator("*");
}
//除号“/”
on (release, keyPress "/") {
getoperator("/");
}

//=
on (release, keyPress "=") {
getoperator();
}

//小数点 “.”
on (release, keyPress ".") {
if (!decimal) {
getdigit(".");
decimal = true;
}
}

//下面是时间的显示

function bb() {
var rq:Date = new Date();
nian = rq.getFullYear();
yue = rq.getMonth()+1;
ri = rq.getDate();
if (rq.getHours()<10) {
shi = "0"+rq.getHours();
} else {
shi = rq.getHours();
}
if (rq.getMinutes()<10) {
fen = "0"+rq.getMinutes();
} else {
fen = rq.getMinutes();
}
if (rq.getSeconds()<10) {
miao = "0"+rq.getSeconds();
} else {
miao = rq.getSeconds();
}
xingqi = rq.getDay();
var xq:Array = new Array("星期天", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六");
t1 = nian+"年"+yue+"月"+ri+"日"+xq[xingqi];
t2 = shi+":"+fen+":"+miao;
}
call(bb());
intervalId = setInterval(this, "bb", 300);
AiPPT
2024-09-19 广告
随着AI技术的飞速发展,如今市面上涌现了许多实用易操作的AI生成工具1、简介:AiPPT: 这款AI工具智能理解用户输入的主题,提供“AI智能生成”和“导入本地大纲”的选项,生成的PPT内容丰富多样,可自由编辑和添加元素,图表类型包括柱状图... 点击进入详情页
本回答由AiPPT提供
百度网友078e04055
2011-06-08
知道答主
回答量:42
采纳率:0%
帮助的人:24.4万
展开全部
用3.0还是2.0呀
追问
2.0
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式