Форум 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)
-   -   проблема с hitTest (http://www.flasher.ru/forum/showthread.php?t=133372)

rem345690 03.12.2009 14:15

проблема с hitTest
 
Двадцать клипов ["mc"+i] при хиттесте с любым из ["m"+i] = какоето действие.

Непонимаю в чём ошибка. Не хиттестится (. Help.




Код:

//
import mx.utils.Delegate;

for (var i:Number = 1; i<=20;i++) {

        this["mc"+i].onPress=function () {
                this.startDrag();
                this.swapDepths(getNextHighestDepth())
               
        }
        this["mc"+i].onRelease=function () {
                this.stopDrag();
               
                if (this.hitTest(["m"+i])) {
                        this._x=["m"+i]._x
                        this._y=["m"+i]._y
                       
                trace ("ок")
                        delete this.onPress;
                        delete this.onRelease;
                }
        }
        }

.

Zik. 03.12.2009 14:38

Код AS1/AS2:

for (var i:Number = 1; i <= 20; i++) {
        this["mc"+i].onPress=function () {
                this.startDrag();
                this.swapDepths(getNextHighestDepth());
        }
        this["mc"+i].onRelease=function () {
                this.stopDrag();
                for (var n:Number = 1; n <= 20; n++) {
                        if (this.hitTest(["m"+n])) {
                                this._x = ["m" + n]._x;
                                this._y = ["m" + n]._y;
                                trace ("ок");
                                delete this.onPress;
                                delete this.onRelease;
                        }
                }
        }
}


rem345690 03.12.2009 14:48

и так не хиттестится.

Zik. 03.12.2009 14:55

Код AS1/AS2:

for (var i:Number = 1; i <= 20; i++) {
        mc = attachMovie("m", "m"+i, i);
        mc.onPress = function():Void {
                trace(9)
                this.startDrag();
                this.swapDepths(getNextHighestDepth());
        }
        mc.onRelease = function():Void {
                this.stopDrag();
                for (var n:Number = 1; n <= 20; n++) {
                        if (this.hitTest(_root["m"+n])) {
                                if (this != _root["m"+n]) {
                                        this._x = ["m" + n]._x;
                                        this._y = ["m" + n]._y;
                                        trace ("ок");
                                        delete this.onPress;
                                        delete this.onRelease;
                                }
                        }
                }
        }
}


rem345690 03.12.2009 15:15

а так и на press не откликается.

Zik. 03.12.2009 15:18

как вы аттачите клипы?

rem345690 03.12.2009 15:22

там без аттачей. просто двадцать одних (mc1,mc2,mc3....) и двадцать других

Zik. 03.12.2009 15:27

тогда исходник

rem345690 03.12.2009 15:28

вот так вот заработало всё

for (var i:Number = 1; i <= 20; i++) {

this["mc"+i].onPress = function():Void {

this.startDrag();
this.swapDepths(getNextHighestDepth());
}
this["mc"+i].onRelease = function():Void {
this.stopDrag();
for (var n:Number = 1; n <= 20; n++) {
if (this.hitTest(_root["m"+n])) {

this._x = _root["m" + n]._x;
this._y = _root["m" + n]._y;

trace ("ок");

delete this.onPress;
delete this.onRelease;

}
}
}
}

Добавлено через 4 минуты
спасибо за помошь. )


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

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