Показать сообщение отдельно
Старый 10.01.2008, 15:49
CrazyFlasher вне форума Посмотреть профиль Отправить личное сообщение для CrazyFlasher Найти все сообщения от CrazyFlasher
  № 2  
Ответить с цитированием
CrazyFlasher
 
Аватар для CrazyFlasher

Регистрация: May 2003
Адрес: Tallinn
Сообщений: 3,182
вот наваял простой пример и, по-моему, очень понятный

создаём 2 класса:
MotherClass.as
Код:
import mx.utils.Delegate;

class MotherClass {
	
	public function MotherClass(){
		var child:ChildClass = new ChildClass();
		
		child.addEventListener("update", Delegate.create(this, callsFromChild));
		child.callMother();
	}
	
	private function callsFromChild(callObj:Object){
		switch(callObj.event){
			case "motherFeedMe":
				trace("ok child, I feed you!");
				break;
				
			default:
				trace("I DON'T UNDERSTAND YOU DEAR CHILD!");
				break;
		}
	}
}
ChildClass.as
Код:
import mx.events.EventDispatcher;

class ChildClass {
	public function ChildClass(){
		EventDispatcher.initialize(this);
	}
	
	public function callMother(){
		dispatchEvent({type:"update", event:"motherFeedMe"});
	}
	
	//dispatcher methods
	public function dispatchEvent():Void {};
	public function addEventListener():Void {};
	public function removeEventListener():Void {};
}
во fla файле пишем:
Код:
var mom:MotherClass = new MotherClass();
__________________
Flash Developer
Папа TDP4 Team Battle