Показать сообщение отдельно
Старый 31.10.2005, 12:15
7thsky™ вне форума Посмотреть профиль Отправить личное сообщение для 7thsky™ Найти все сообщения от 7thsky™
  № 5  
Ответить с цитированием
7thsky™
Flash Aксакал
 
Аватар для 7thsky™

Регистрация: Jun 2005
Сообщений: 636
только fps побольше поставь - 31 например

Код:
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();
};

getListPrototype = function () {
	var o = new Object ();
	
	o.__proto__ = MovieClip.prototype;
	o.offset = null;
	o.x1 = null;
	o.x2 = null;
	o.xMin = null;
	o.xMax = null;
	o.k = null;
	o.destination = null;
	
	o.init = function (offset) {
		this.offset = offset;
		
		// вычисляем
		var s1 = this.container._width - this.mask._width;
		var s2 = this.mask._width - this.offset * 2;
		
		this.xMin = 0;
		this.xMax = this.mask._width;
		this.yMin = 0;
		this.yMax = 50;
		this.x1 = this.xMin + this.offset;
		this.x2 = this.xMax - this.offset;
		this.destination = 0;
		this.k = s1 / s2;
		
		this.mask.onEnterFrame = function () {
			this._parent.__onEnterFrame ();
		};
	};
	
	o.__onEnterFrame = function () {
		var x = this._xmouse;
		var y = this._ymouse;
		
		if (y > this.yMin && y < this.yMax) {
			x = Math.max (x, this.x1);
			x = Math.min (x, this.x2);
			x -= this.x1;
			
			this.destination = - x * this.k;
			this.__mover ();
		} // end if
	};
	
	o.__mover = function () {
		var x = this.destination;
		var k = (x - this.container._x ) * .3;
		if (Math.abs (k) < .3) {
			this.container._x = x;
		} else {
			this.container._x += k;
		} // end if
	};
	
	return o;
}

getListItemPrototype = function () {
	var o = new Object ();
	o.__proto__ = MovieClip.prototype;
	
	o.init = function (index, width, height) {
		this.drawRect (0, 0, 50, 50, 0x00FFF0, 100);
		this.createTextField ('txt', 1, 0, 0, 20, 20);
		this.txt.text = index;
		this._alpha = 40;
	};
	
	o.onRollOver = function () {
		this._alpha = 80;
	};
	
	o.onRollOut = function () {
		this._alpha = 40;
	};
	
	return o;
}

main = function () {
	var pane = this.createEmptyMovieClip ('pane', 1);
	var itemPrototype = getListItemPrototype ();
	var itemContainer = pane.createEmptyMovieClip ('container', 1);
	
	// cоздаем айтемы
	for (var i = 0; i < 50; i++) {
		var mc = itemContainer.createEmptyMovieClip ('item' + i, i);
		
		// назначаем класс
		mc.__proto__ = itemPrototype;
		mc.init (i, 50, 50);
		
		// позиция
		mc._x = 55 * i;
	} // end for
	
	// маска
	var mask = pane.createEmptyMovieClip ('mask', 2);
	mask.drawRect (0, 0, Stage.width, 50, 0x0ff000, 100);
	mask._alpha = 0;
	
	// накладываем маску
	pane.setMask (mask);
	
	
	// накладываем прототип
	pane.__proto__ = getListPrototype ();
	pane.init (50);
};

main ();