|
|
|||||
Регистрация: Apr 2018
Сообщений: 2
|
Не работает таймер
Разрабатываю модель лабораторной работы по физике "Математический маятник". Необходимо сделать секундомер, чтобы запускался по клавише пробел. Секундомер есть, работает, но только если в отдельном документе. Когда добавляю в свой документ с лабораторной работой либо не работает (если есть код калькулятора), либо работает, но только по нажатию мыши, на пробел никак не реагирует (если удалить код калькулятора). Подскажите, с чем это может быть связано и как исправить?
|
|
|||||
код скиньте сюда,
специалист по чтению кода на расстоянии у нас в отпуске |
|
|||||
Регистрация: Apr 2018
Сообщений: 2
|
Добавила во вложение архив с секундомером в отдельном флэш-документе, модель маятника не загружается, так как большой файл. Скину сюда код, который конкретно находится на кадре, где хочу добавить секундомер:
// 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(); } Возможно, подскажите другой вариант секундомера по кнопке. Последний раз редактировалось Zebestov; 29.04.2018 в 11:15. |
|
|||||
Lorem ipsum
|
Код следует оформлять соответствующими тегами.
__________________
Поймай яблоко 2! |
Часовой пояс GMT +4, время: 06:44. |
|
« Предыдущая тема | Следующая тема » |
|
|