![]() |
|
||||||||||
|
|||||||
|
|
« Предыдущая тема | Следующая тема » |
| Опции темы | Опции просмотра |
|
![]() |
![]() |
|
|||||
|
Регистрация: Oct 2002
Адрес: СПБ
Сообщений: 58
|
Циклом for создаются пустые мувы, в них рисуются квадраты...
Как сделать, чтобы потом эти мувы можно было таскать? |
|
|||||
|
Регистрация: Oct 2005
Адрес: Russia, Irkutsk
Сообщений: 742
|
опробуй помутить с методом startDrag("имя мува"); где-то на форуме лежали ссылки на словарь AS на русском яз. Там про этот метод усё расписано...
__________________
smival.com |
|
|||||
|
Flash Aксакал
Регистрация: Jun 2005
Сообщений: 636
|
MovieClip.prototype.drawRect = function (x, y, width, height, color, alpha) {
this.beginFill (color, alpha);
this.moveTo (x, y);
this.lineTo (x + width, y);
this.lineTo (x + width, y + height);
this.lineTo (x, y + height);
this.lineTo (x, y);
this.endFill ();
}
this.draw = function (container, prototypeObject) {
if (typeof container == 'movieclip') {
for (var i = 0; i < 10; i++) {
var mc = container.createEmptyMovieClip ('mc' + i, i);
var color = Math.floor (Math.random () * 16000000);
var alpha = 50 + 50 * Math.random ();
var width = 100 + 100 * Math.random ();
var height = 70 + 70 * Math.random ();
var x = Stage.width * Math.random ();
var y = Stage.height * Math.random ();
mc.__proto__ = prototypeObject;
mc._x = x; mc._y = y;
mc.init (width, height, color, alpha);
} // end for
} // end if
};
var o = new Object ();
o.__proto__ = MovieClip.prototype;
o.yy = null;
o.xx = null;
o.init = function (width, height, color, alpha) {
// рисуем квадрат
this.drawRect (0, 0, width, height, color, alpha);
// определяем обработчик
this.onPress = this.__onPress;
};
o.__onPress = function () {
this.yy = this._ymouse;
this.xx = this._xmouse;
this.onRelease = this.__onRelease;
this.onReleaseOutside = this.__onRelease;
this.onEnterFrame = this.__onEnterFrame;
};
o.__onRelease = function () {
this.onEnterFrame ();
delete this.onEnterFrame;
delete this.onRelease;
delete this.onReleaseOutside;
};
o.__onEnterFrame = function () {
var y = this._parent._ymouse - this.yy;
var x = this._parent._xmouse - this.xx;
var k;
// x
k = (x - this._x) * .3;
if (Math.abs (k) < .3) {
this._x = x;
} else {
this._x += k;
} // end if
// y
k = (y - this._y) * .3;
if (Math.abs (k) < .3) {
this._y = y;
} else {
this._y += k;
} // end if
};
this.draw (this, o);
Последний раз редактировалось 7thsky™; 31.10.2005 в 11:54. |
|
|||||
|
Регистрация: Jan 2002
Адрес: СПб-Denver-Лермонтов
Сообщений: 1,525
|
7thsky™, ну зачем такие сложности, особенно для новичка? Можно же намного проще.
MovieClip.prototype.qqq = function(){
this.beginFill (random(16000000), random(80)+20);
this.moveTo (0, 0);
this.lineTo (100, 0);
this.lineTo (100, 100);
this.lineTo (0, 100);
this.lineTo (0, 0);
this.endFill ();;
this.onPress = function(){
startDrag(this,false);
}
this.onRelease = this.onReleaseOutside = function(){
stopDrag();
}
}
for(i=0;i<10;i++){
this.createEmptyMovieClip("mc"+i,i);
this["mc"+i]._x = random(500)+30;
this["mc"+i]._y = random(300)+30;
this["mc"+i].qqq();
}
__________________
Для того чтобы узнавать, есть два способа: - задавать вопросы и пытаться самому на них ответить. Второй способ более продуктивный. (S.Wizard) |
|
|||||
|
Flash Aксакал
Регистрация: Jun 2005
Сообщений: 636
|
ну можно и так
Только я не люблю в прототипе прописывать то чего там быть не должно, а то потом вдруг вставляешь один проект в другой смотришь в прототипе функции дублируются ![]() |
|
|||||
|
Регистрация: Oct 2002
Адрес: СПБ
Сообщений: 58
|
Блин, я жутко тормозил
Я делал способом sergwizard, токо startDrag применялся к ещё не созданному муву, а не через ths ... ![]() |
![]() |
![]() |
Часовой пояс GMT +4, время: 10:58. |
|
|
« Предыдущая тема | Следующая тема » |
|
|