Форум 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=100314)

mayday 24.08.2007 10:36

Отслеживание движения мыши
 
Вложений: 1
Задача: сделать так, чтобы при неподвижности мыши прекращалось действие .. В данном случае _rotation должен быть равен 0.
Исходник прилагаю ..
Каким способом можно это сделать?

Код:

zero = (Stage.width/2 - _xmouse);
shag = (car._x - _xmouse)*1.8;

car._x = Stage.width/2;

var mouseListener:Object = new Object();

mouseListener.onMouseMove = function(){       
        shag = (car._x - _xmouse)*1.8;       
        onMouseDown = function(){       
                car.onEnterFrame = function(){
                        car._x = _xmouse;                       
                        if (_xmouse >= zero){
                                car.w1._rotation -= shag;
                                car.w2._rotation -= shag;                               
                        } else {
                                car.w1._rotation += shag;
                                car.w2._rotation += shag;                               
                        }
                }
        }
       
        onMouseUp = function(){
                car.onEnterFrame = function(){
                        car.w1._rotation == 0;
                        car.w2._rotation == 0;
                }
        }
}

Mouse.addListener(mouseListener);


CorC 24.08.2007 10:38

убрать onEnterFrame или как нибудь его заменить

Жень Шень 24.08.2007 10:56

Привет!
Код:

zero = (Stage.width/2-_xmouse);
car._x = Stage.width/2;
var mouseListener:Object = new Object();
mouseListener.onMouseMove = function() {
        onMouseDown = function () {
                car.onEnterFrame = function() {
                        shag = (car._x-_xmouse)*1.8;
                        car._x = _xmouse;
                        if (_xmouse>=zero) {
                                car.w1._rotation -= shag;
                                car.w2._rotation -= shag;
                        } else {
                                car.w1._rotation += shag;
                                car.w2._rotation += shag;
                        }
                };
        };
        onMouseUp = function () {
                car.onEnterFrame = function() {
                        car.w1._rotation == 0;
                        car.w2._rotation == 0;
                };
        };
};
Mouse.addListener(mouseListener);


udaaff 24.08.2007 10:56

Код:

car.onPress = function() {
        this.startDrag(false, 0, this._y, Stage.width, this._y);
        this.onMouseMove = function() {
                //вращаем колеса
        };
};
car.onRelease = car.onReleaseOutside=function () {
        stopDrag();
        delete this.onMouseMove;
};


mayday 24.08.2007 11:10

Всем большое спасибо, работает!

:yahoo:


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

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