Форум Flasher.ru
Ближайшие курсы в Школе RealTime
Список интенсивных курсов: [см.]  
  
Специальные предложения: [см.]  
  
 
Блоги Правила Справка Пользователи Календарь Сообщения за день
 

Вернуться   Форум Flasher.ru > Flash > ActionScript 1.0/2.0

Версия для печати  Отправить по электронной почте    « Предыдущая тема | Следующая тема »  
Опции темы Опции просмотра
 
Создать новую тему  
Старый 06.06.2008, 01:44
Eugenicsbmx вне форума Посмотреть профиль Найти все сообщения от Eugenicsbmx
  № 2  
Ответить с цитированием
Eugenicsbmx
Banned
 
Аватар для Eugenicsbmx

Регистрация: Jan 2008
Сообщений: 85
Вот класс подгружаемый в сцену
Код:



class Dock extends MovieClip {
	var vz:Boolean=false;// Изчезновение
    
    function onLoad() {
        this._alpha = 5;
        vz = false;
    }

    function onRollOver() {
        vz = true;
    }
    function onRollOut() {
        vz = false;
    } // Изчезновение

	var icon_min		: Number;	//Минималный размер иконки.
	var icon_max		: Number;	//Максимальный размер иконки.
	var icon_size		: Number;	//Натуральный размер иконки.
	var icon_spacing	: Number;	//Промежутки между иконками
	var width			: Number;	//Ширина чего-то (!)
	var span			: Number;	//Задействованные иконки про движении (длинна).
	var amplitude		: Number;	//Для нужд класса
	var ratio			: Number;	//Для нужд класса
	var scale			: Number = Number.NEGATIVE_INFINITY; //Хз
	var trend			: Number = 0;	//Хз
	var xmouse			: Number;	//Позиция крысы
	var ymouse			: Number;	//Сэйм шит
	var layout			: String;	//Вывод..
	var callback		: Function;	//Функция
	var items			: Array;	//Массив элементов

	function Dock() {		//Инициализация класса Dock
		setParameters();
		setLayout();
		createIcons();
		createTray();
		onEnterFrame = monitorDock;	//Мониторинг менюшки..
	}

	private function setParameters():Void {
		this.layout = this.layout ? this.layout : 'bottom';						//Если параметр this.layout не задан, то положение менюшки снизу
		this.icon_min = this.icon_min ? this.icon_min : 32;						//Если не задан минимальный размер то он 32
		this.icon_max = this.icon_max ? this.icon_max : 96;						//-||- максимальный, то он 96
		this.icon_spacing = this.icon_spacing ? this.icon_spacing : 2;			// Расстояние между иконками.
		this.span = this.span ? this.span : getSpan();							// если не заданно растяжение,то оно вычисляется..
		this.amplitude = this.amplitude ? this.amplitude : getAmplitude();
		this.ratio =  Math.PI / 2 / this.span;
	}

	private function getSpan():Number {			//Функция задействованной области.
		return (this.icon_min - 16) * (240 - 60) / (96 - 16) + 60;
	}

	private function getAmplitude():Number {	//Функция вычисления длинны волны.
		return 2 * (this.icon_max - this.icon_min + this.icon_spacing);
	}

	private function createIcons():Void {		//Функция рисования иконок.
		var i:Number;							//Кол-во иконок.
		var id:String;							//Наименование иконки.
		this.scale = 0;							//Жуй знает
		this.width = (this.items.length - 1) * this.icon_spacing + this.items.length * this.icon_min;	//Просчёт ширины (полоски)
		var left:Number = (this.icon_min - this.width) / 2;  //Смещение влево при наведении (центровка)
		for(i = 0; i < this.items.length; i++) {	//Пробегаемся циклом по массиву
			this.createEmptyMovieClip(String(i), 10 + i).attachMovie(this.items[i].id, '_mc', 1);	//Создаём мувиклип иконки
			this[i]._mc._y = -this.icon_size / 2;		//Смещение контейнера.
			this[i]._mc._rotation = -this._rotation;	//Поворот иконки(!)
			this[i]._x = this[i].x = left + i * (this.icon_min + this.icon_spacing) + this.icon_spacing / 2; //Смещение иконки.
			this[i]._y = -this.icon_spacing;	// --||--
			this[i].onRelease = launchIcon;		// Вызов функции при нажатии.
			this[i].onRollOver = createMouseCursor;		// Вызов функции при наведении.
			this[i].onRollOut = destroyMouseCursor;		// Вызов функции при "Уведении" :).
			//this[i].useHandCursor = false;		// Убрать курсор руки.
			
			this[String(i)].createTextField('mytext', this.getNextHighestDepth(), -64, -14, 128, 16); // Создание непосредственно самого текстового поля
			with(this[String(i)].mytext) {
				styleSheet = _root.styles;
				htmlText = "<bodyText>" + this.items[i].description + "</bodyText>";
				embedFonts = true;
			}
		}
	}

	private function launchIcon():Void {		//Функция, вызванная нажатием.
		this._parent.callback(this._parent.items[this._name].label); //Вызов функции описанной в мвиклипе.
	}

	private function createMouseCursor():Void {
		Mouse.hide();
		_root.attachMovie('cursor', 'cursor', _root.getNextHighestDepth(), {_x: _root._xmouse, _y: _root._ymouse});
		_root.cursor.startDrag(true);
		updateAfterEvent();
	}

	private function destroyMouseCursor():Void {
		Mouse.show();
		_root.cursor.removeMovieClip();
	}

	private function createTray():Void {		//Рисование заднего фона (програмное \м/)
		var height:Number = this.icon_min - 2 * this.icon_spacing; // изменил "+" на "-" (Я)
		var width:Number = this.width - 2 * this.icon_spacing; // изменил "+" на "-" (Я)
		var mc:MovieClip = this.createEmptyMovieClip('tray_mc', 1);
		//mc.lineStyle(0, 0xcccccc, 80);
		//mc.beginFill(0xe8e8e8, 50);
		//mc.lineTo(0, -height);
		//mc.lineTo(width, -height);
		//mc.lineTo(width, 0);
		//mc.lineTo(0, 0);
		//mc.endFill();
	}

	private function setLayout():Void {		//Определяется вывод меню
		switch(this.layout) {
			case 'left':
				this._rotation = 90;
				break;
			case 'top':
				this._rotation = 180;
				break;
			case 'right':
				this._rotation = 270;
				break;
			default:
				this._rotation = Number(this.layout);
		}
	}

	private function checkBoundary():Boolean {	//Выявление границы, в которых задействованна крыса :) ну и намутили...
		var buffer:Number = 4 * this.scale;
		return (this.ymouse < 1)
			&& (this.ymouse > -2 * this.icon_spacing - this.icon_min + (this.icon_min - this.icon_max) * this.scale)
			&& (this.xmouse > this[0]._x - this[0]._width / 2 - this.icon_spacing - buffer)
			&& (this.xmouse < this[this.items.length - 1]._x + this[this.items.length - 1]._width / 2 + this.icon_spacing + buffer);
	}

	private function updateTray():Void {		// Обновление ширины задней полоски.
		var x:Number;
		var w:Number;
		x = this[0]._x - this[0]._width / 2 - this.icon_spacing;
		w = this[this.items.length - 1]._x + this[this.items.length - 1]._width / 2 + this.icon_spacing;
		this['tray_mc']._x = x;
		this['tray_mc']._width = w - x;
	}

	private function monitorDock():Boolean {	//Функция отслеживания
		var i:Number;
		var x:Number;
		var dx:Number;
		var dim:Number;
		if (vz == true) {                   // Изчезновение
            if (this._alpha<100) {
                this._alpha += 5;
            }
        }
        if (vz == false) {
            if (this._alpha>=10) {
                this._alpha -= 5;
            }
        }                                  // Изчезновение

		// Крыса не двигается и меню не находится между стадиями
		if((this.xmouse == this._xmouse) && (this.ymouse == this._ymouse) && ((this.scale <= 0.01) || (this.scale >= 0.99))) { return false; }

		// Крыса двинулась или меню во время стадии. Обновить док.
		this.xmouse = this._xmouse;
		this.ymouse = this._ymouse;

		// Гарантия, что задействование не изменит направление (???)
		this.trend = (this.trend == 0 ) ? (checkBoundary() ? 0.25 : -0.25) : (this.trend);
		this.scale += this.trend;
		if( (this.scale < 0.02) || (this.scale > 0.98) ) { this.trend = 0; }

		// Натуральный размер нахдится между 0 и 1
		this.scale = Math.min(1, Math.max(0, this.scale));

		// Жуть редкая :) вычисление позиций иконок и просчёт их размера ;)
		for(i = 0; i < this.items.length; i++) {
			dx = this[i].x - this.xmouse;
			dx = Math.min(Math.max(dx, -this.span), this.span);
			dim = this.icon_min + (this.icon_max - this.icon_min) * Math.cos(dx * this.ratio) * (Math.abs(dx) > this.span ? 0 : 1) * this.scale;
			this[i]._x = this[i].x + this.scale * this.amplitude * Math.sin(dx * this.ratio);
			this[i]._xscale = this[i]._yscale =  100 * dim / this.icon_size;
			this[String(i)].mytext._alpha = (this[i]._xscale - 38) * 2;
		}

		// Изменить размер задника.
		updateTray();
		return true;
	}

}
Никак не могу откалибровать положение мувика на сцене, незнаю где именно те параметры что нужно изменить юзал вот эти:
Код:
var dockTemplate = {
	layout: "center", /* top | right | bottom | left | *rotation* */
	icon_size: 128,
	icon_min: 70,
	icon_max: 128,
	icon_spacing: 30,
	items: myArray,
	span: 170,
	amplitude: 90,
	callback: this.dockActions
}

this.attachMovie('Dock', 'menu_mc', 1, dockTemplate);
this.menu_mc._x = Stage.width / 2;
this.menu_mc._y = Stage.height/  2;
Ширину длину когда меняешь меняет и положение мувик, но он как то странно себя ведет и меняет положение как попало.

Создать новую тему   Часовой пояс GMT +4, время: 19:45.
Быстрый переход
  « Предыдущая тема | Следующая тема »  

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.


 


Часовой пояс GMT +4, время: 19:45.


Copyright © 1999-2008 Flasher.ru. All rights reserved.
Работает на vBulletin®. Copyright ©2000 - 2026, Jelsoft Enterprises Ltd. Перевод: zCarot
Администрация сайта не несёт ответственности за любую предоставленную посетителями информацию. Подробнее см. Правила.