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

shreck 06.10.2007 15:09

Эффект прилипания
 
Как можно реализовать эффект прилипания к краям экрана?

Mnilionic 06.10.2007 17:13

прилипание рук или чего?

udaaff 06.10.2007 17:18

Цитата:

Сообщение от shreck
Как можно реализовать эффект прилипания к краям экрана?

Если имеется ввиду прилипание мувика к краям сцены:
Код:

var rect:MovieClip = createRect(this, "rect", this.getNextHighestDepth, 50, 50);

rect.onPress = function() {
        this.startDrag(false);
};

rect.l = 20;

rect.onRelease = rect.onReleaseOutside=function () {
        this.stopDrag();
        if (this._x>=0 && this._x<this.l) {
                this._x = 0;
        } else if (this._x+this._width<=Stage.width && this._x+this._width>=Stage.width-this.l) {
                this._x = Stage.width-this._width-1;
        }
        if (this._y>=0 && this._y<this.l) {
                this._y = 0;
        } else if (this._y+this._height<=Stage.height && this._y+this._height>=Stage.height-this.l) {
                this._y = Stage.height-this._height-1;
        }
};

function createRect(cont:MovieClip, name:String, depth:Number, width:Number, height:Number):MovieClip {
        var rect:MovieClip = cont.createEmptyMovieClip(name, depth);
        with (rect) {
                beginFill(0x00FF00, 100);
                lineStyle(0);
                lineTo(width, 0);
                lineTo(width, height);
                lineTo(0, height);
                lineTo(0, 0);
                endFill();
        }
        return rect;
}


shreck 08.10.2007 15:37

udaaff, спасибо, то что нужно. Респект


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

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