Форум Flasher.ru

Форум Flasher.ru (http://www.flasher.ru/forum/index.php)
-   Общие вопросы о Flash (не затрагивающие ActionScript) (http://www.flasher.ru/forum/forumdisplay.php?f=60)
-   -   action готов. осталась суммировать. (http://www.flasher.ru/forum/showthread.php?t=74818)

mrulala 29.01.2006 14:42

action готов. осталась суммировать.
 
в следующем коде нужно чтобы в какую-нибудь переменную сохранялась сумма всех длинн. т.е. есть переменная dlinna и надо например в переменную dlinnasum сохранять длины всех векторов.

Код:

this.createEmptyMovieClip("canvas_mc", this.getNextHighestDepth());
var mouseListener:Object = new Object();
mouseListener.onMouseDown = function() {
        this.isDrawing = true;
        this.orig_x = _xmouse;
        this.orig_y = _ymouse;
        coordinatex = _xmouse;
        coordinatey = _ymouse;
        this.target_mc = canvas_mc.createEmptyMovieClip("", canvas_mc.getNextHighestDepth());
};
mouseListener.onMouseMove = function() {
        if (this.isDrawing) {
                this.target_mc.clear();
                this.target_mc.lineStyle(1, 0xFF0000, 100);
                this.target_mc.moveTo(this.orig_x, this.orig_y);
                this.target_mc.lineTo(_xmouse, _ymouse);
                this.target_mc.lineTo(this.orig_x, this.orig_y);
        }
        updateAfterEvent();
};
mouseListener.onMouseUp = function() {
        coordinatex1 = _xmouse;
        coordinatey1 = _ymouse;
        katety = Math.abs(coordinatey-coordinatey1);
        katetx = Math.abs(coordinatex-coordinatex1);
        dlinna = Math.sqrt(katetx*katetx+katety*katety);
        this.isDrawing = false;
       
};
Mouse.addListener(mouseListener);

сам не могу. ломаю голову целый день.
заранее спасибо.

Antares 29.01.2006 16:10

Пользуемся тэгом code

MOHCTEP 29.01.2006 18:08

Код:

this.createEmptyMovieClip("canvas_mc", this.getNextHighestDepth());
var dlinasum:Number=0;
var mouseListener:Object = new Object();

....

mouseListener.onMouseUp = function() {
        coordinatex1 = _xmouse;
        coordinatey1 = _ymouse;
        katety = Math.abs(coordinatey-coordinatey1);
        katetx = Math.abs(coordinatex-coordinatex1);
        dlinna = Math.sqrt(katetx*katetx+katety*katety);
            dlinasum+=dlinna;
        this.isDrawing = false;
       
};
Mouse.addListener(mouseListener);



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

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