Показать сообщение отдельно
Старый 27.12.2005, 01:54
BlooDHounD вне форума Посмотреть профиль Отправить личное сообщение для BlooDHounD Посетить домашнюю страницу BlooDHounD Найти все сообщения от BlooDHounD
  № 18  
Ответить с цитированием
BlooDHounD
стервочка (я мужик)
 
Аватар для BlooDHounD

блогер
Регистрация: Mar 2004
Адрес: Борисов
Сообщений: 3,161
Записей в блоге: 22
ну вот пример моего события ... оно конечно примитивно ... но для моего случия подходит
Код:
package game.events
{
	import flash.events.Event;

	public final class MonsterEvent extends Event
	{
		private var m_direction:String;
		
		public function MonsterEvent(type:String, direction:String, bubbles:Boolean=false, cancelable:Boolean=false)
		{
			super(type, bubbles, cancelable);
			this.m_direction = direction;
		}
		
		public override function clone():Event
		{
			return new MonsterEvent(this.type, this.m_direction, this.bubbles, this.cancelable);
		}

		public override function toString():String
		{
			return formatToString("MonsterEvent", "type", "direction", "bubbles", "cancelable");
		}

		public function get direction():String
		{
			return this.m_direction;
		}
	}
}
Юзается это потом приблизительно так:
Код:
		private function doMove(event:Event):Void
		{
			switch (this._direction)
			{
				case MonsterDirection.LEFT: this.x -= this._speed; break;
				case MonsterDirection.RIGHT: this.x += this._speed; break;
				case MonsterDirection.TOP: this.y -= this._speed; break;
				case MonsterDirection.BOTTOM: this.y += this._speed; break;
				default: return;
			}
			this.dispatchEvent(new MonsterEvent(MonsterEventType.MONSTER_MOVE, this._direction));
		}