Цитата:
|
Сообщение от 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;
}