Показать сообщение отдельно
Старый 03.12.2009, 12:52
a_web вне форума Посмотреть профиль Отправить личное сообщение для a_web Найти все сообщения от a_web
  № 4  
Ответить с цитированием
a_web

Регистрация: Sep 2009
Сообщений: 12
Инициализация ролика

Код AS1/AS2:
//Инициализируем вопрос
function InitQuestion(ScaleUrl:String, ItemUrl:String)
{
	Params = new InitialPars(ScaleUrl, ItemUrl);
 
	//Вставляем линейку
	if (Params.ScaleUrl != "")
	{		
		//делаем клип
		var ScaleMCL:MovieClipLoader = new MovieClipLoader();
		var ScaleCompleteListener:Object = new Object();
 
		ScaleMCL.addListener(ScaleCompleteListener);
		ScaleCompleteListener.onLoadInit = 
			function (SrcClip)
			{
				SrcClip._x = 0;
				SrcClip._y = DocumentHeight - SrcClip._height;
			}
 
		ScaleClip = _root.createEmptyMovieClip ("_scale", _root.getNextHighestDepth());
		ScaleMCL.loadClip(ScaleUrl, ScaleClip);
	}
 
	len = Params.Items.length;
	ItemClip = new Array(len);
	ValueOut = new Array(len);
	var ItemImage:Array = new Array(len);
 
	//Собираем ползунки
	for (i = 0; i < len; i++)
	{
		var ItemMCL:MovieClipLoader = new MovieClipLoader();
		var ItemCompleteListener:Object = new Object();
 
		ItemMCL.addListener(ItemCompleteListener);
		ItemCompleteListener.onLoadInit = 
			function (SrcClip)
			{
				id = SrcClip._name.split(".")[1];
 
				SrcClip._parent.height = (SrcClip._height + 40) * 2;
				SrcClip._y = (SrcClip._height + 40) / 2;
				PointerClip = SrcClip._parent.attachMovie("pointer", "_pointer", SrcClip._parent.getNextHighestDepth());
				PointerClip._x = (SrcClip._width / 2) - 10;
				PointerClip._y = SrcClip._y + SrcClip._height;
 
				SrcClip._parent._y = DocumentHeight - (ScaleClip == null ? 0 : ScaleClip._height) - (SrcClip._parent.height * 0.75) - Params.Removal;
				dragAndDrop(SrcClip._parent, SrcClip._parent._y, 71, parseInt(id));
			}
 
		ItemClip[i] = _root.createEmptyMovieClip ("_item." + i.toString(), _root.getNextHighestDepth());
		ItemImage[i] = ItemClip[i].createEmptyMovieClip ("_image." + i.toString(), ItemClip[i].getNextHighestDepth());
 
		ItemMCL.loadClip(Params.Items[i], ItemImage[i]);
	}
 
}
событие перетаскивания
Код AS1/AS2:
function dragAndDrop(clip:MovieClip, initY, initDelta, index):Void
{
	clip.onPress = 
		function()
		{
			var oldX = this._x;
			var newX = oldX;
			var oldY = initY;
			var newY = oldY;
 
 
			this.swapDepths(_root.getNextHighestDepth());
			...
		}
	...
}