
10.11.2005, 19:08
|
|
Регистрация: Nov 2003
Сообщений: 128
|
теперь банановый
//init line
lineStyle (0, 0);
for (i = 0; i < 11; i++) {
moveTo (0, i * 40);
lineTo (400, i * 40);
moveTo (i * 40, 0);
lineTo (i * 40, 400);
}
// init clip
createEmptyMovieClip ("mc", 0);
// shape size
var s = 90;
mc.lineStyle (0, 0xFF0000);
mc.beginFill (0xFF0000, 50);
mc.lineTo (s, 0);
mc.lineTo (s, s);
mc.lineTo (0, s);
mc.lineTo (0, 0);
mc.endFill ();
//
mc.onPress = function () {
this.startDrag();
};
mc.onRelease = mc.onReleaseOutside = function () {
this.stopDrag();
var x1 = Math.round (this._x / 40);
var y1 = Math.round (this._y / 40);
var dx1 = this._x - x1 * 40;
var dy1 = this._y - y1 * 40;
var x2 = Math.round ((this._x + this._width) / 40);
var y2 = Math.round ((this._y + this._height) / 40);
var dx2 = Math.abs(this._x + this._width - x2 * 40);
var dy2 = Math.abs(this._y + this._height - y2 * 40);
if (dx1 < dx2)
this._x = x1 * 40
else
this._x = x2 * 40 - this._width;
if (dy1 < dy2)
this._y = y1 * 40
else
this._y = y2 * 40 - this._height;
};
|