inilah coding pada action-framenya :
// Initialize the calculator variables
memory = 0;
sp = "0";
display = 0;
// Variable to set inv mode
flag_inv = 0;
display_flag = 0;
point = false;
// Variable for seeting off button's function
off_flag = false;
if (off_flag == true) {
offcheck1();
}
stop ();
// Function to set Off button
function offCheck1 () {
off_flag = true;
display = "";
}
// Function to set ON button
function offCheck () {
off_flag = false;
}
// Function for max values to be entered
function dispflag () {
if (display_flag<15) {
display_flag = display_flag+1;
return dispno=true;
} else {
return dispno=false;
}
}
function AddDigit (digit) {
// Add a digit to display
if (clear) {
clear = false;
decimal = false;
display = "0";
}
if (dispno=true) {
if (display == "0" and digit != ".") {
display = digit;
} else {
display = display+digit;
}
} else {
}
}
function DoInverse (flag) {
if (flag == 0) {
return setflag=true;
} else {
return setflag=false;
}
}
function DoOperator (newOper) {
// Perform an operation
// Addition
if (operator == "+") {
display = Number(operand1)+Number(display);
}
// Subtraction
if (operator == "-") {
display = operand1-display;
}
// Multiplication
if (operator == "*") {
display = operand1*display;
}
// Division
if (operator == "/") {
display = operand1/display;
}
// Following code performs x rest to y operation
if (operator == "x_rest_y") {
display = Math.pow(Number(operand1), Number(display));
}
// Number in to 10 rest to value
if (operator == "exp1") {
display = Number(operand1)*Math.pow(Number(10), Number(display));
}
operator = "=";
clear = true;
decimal = false;
if (newOper != null) {
operator = newOper;
operand1 = display;
}
}
// This function will refresh/flush the status after the result
// This function will start from new digit after getting result as "Infinity"
function refresh () {
operator = "=";
clear = true;
decimal = false;
Status ="";
if (newOper != null) {
operator = newOper;
operand1 = display;
}
}
// The following function will find 1/x value
// It gives the direct result similarly like pressing equal to sign
function one_by_x1 () {
display = Number(1/display);
refresh();
}
// Function to display square of the no.
function x_square () {
display = Number(display*display);
refresh();
}
// Function to display value of Pie
function disp_pi () {
display = Number(Math.PI);
}
// Function to change prefix plus and minus of number
function plus_minus () {
if (display != 0) {
display = Number(-1*display);
} else {
display = Number(display);
}
}
// Sine of the angle in degree
function DoSin () {
display = (Math.sin((display*Math.PI/180)));
refresh();
}
// Find sin inv of the no.
function DoaSin () {
display = Math.asin(display)*(180/Math.PI);
setflag = false;
setProperty (check_inv, _visible, 0);
flag_inv = 0;
refresh();
}
// CoSine of the angle in degree
function DoCos () {
if (display == 90) {
display = 0;
} else {
display = (Math.cos((display*Math.PI/180)));
Status = "";
}
refresh();
}
// Find cos inv of the no.
function DoaCos () {
display = Math.acos(display)*(180/Math.PI);
setflag = false;
setProperty (check_inv, _visible, 0);
flag_inv = 0;
refresh();
}
// Tangent of the angle in degree
function Dotan () {
if (display == 90) {
display = "Infinity";
} else {
display = Math.tan((display*Math.PI/180));
}
refresh();
}
// Find tan inv of the no.
function Doatan () {
display = Math.atan(display)*(180/Math.PI);
setflag = false;
setProperty (check_inv, _visible, 0);
flag_inv = 0;
}
function DoLogNatural () {
display = Math.log(display);
refresh();
}
// Factorial of the no.
function DoN_factorial () {
// var "display" is typecasted to int
disp_fact = int(display);
// A Trick to to check wheather the value is integer or not
test = display-disp_fact;
if (test>0) {
display = "infinity";
break;
// if number is zero then factorial = 1
} else if (disp_fact>100) {
display = "Infinity";
break;
} else if (disp_fact == 0) {
display = 1;
Status = "";
} else {
for (i=1; i<disp_fact; i++) {
display = display*i;
}
}
refresh();
}
untuk mendownload file yang berekstensi fla klik disini
No comments:
Post a Comment