Форум Flasher.ru

Форум Flasher.ru (http://www.flasher.ru/forum/index.php)
-   ActionScript 1.0/2.0 (http://www.flasher.ru/forum/forumdisplay.php?f=93)
-   -   Не работает таймер (http://www.flasher.ru/forum/showthread.php?t=215462)

Anastasiamilova 24.04.2018 22:41

Не работает таймер
 
Разрабатываю модель лабораторной работы по физике "Математический маятник". Необходимо сделать секундомер, чтобы запускался по клавише пробел. Секундомер есть, работает, но только если в отдельном документе. Когда добавляю в свой документ с лабораторной работой либо не работает (если есть код калькулятора), либо работает, но только по нажатию мыши, на пробел никак не реагирует (если удалить код калькулятора). Подскажите, с чем это может быть связано и как исправить?

caseyryan 25.04.2018 13:25

Цитата:

Подскажите, с чем это может быть связано
С ошибками в коде
Цитата:

и как исправить?
Написать код без ошибок

(с) Ваш кэп

Кот Баюн 25.04.2018 16:11

код скиньте сюда,
специалист по чтению кода на расстоянии у нас в отпуске :)

Anastasiamilova 28.04.2018 13:33

Вложений: 1
Добавила во вложение архив с секундомером в отдельном флэш-документе, модель маятника не загружается, так как большой файл. Скину сюда код, который конкретно находится на кадре, где хочу добавить секундомер:


Код AS1/AS2:

// 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

Код следует оформлять соответствующими тегами.


Часовой пояс GMT +4, время: 22:51.

Copyright © 1999-2008 Flasher.ru. All rights reserved.
Работает на vBulletin®. Copyright ©2000 - 2026, Jelsoft Enterprises Ltd. Перевод: zCarot
Администрация сайта не несёт ответственности за любую предоставленную посетителями информацию. Подробнее см. Правила.