I used the cairngorm event dispatcher and you don't need to use all of
cairngorm to use it..
Its like a central dispatcher...
so your component out there that wants to dispatch a "user selected a
date" event..
var dateSelectedEvent = new DateSelectedEvent();
dateSelectedEvent.startdate = someDate;
CairngormEventDispatcher.getInstance().dispatchEvent(dateSelectedEvent);
now in the objects that need to listen you may have :
CairngormEventDispatcher.getInstance().addEventListener(DateSelectedEven
t.type, onDateSelected);
private function onDateSelected(event:CairngormEvent)
{
trace("got a date selected event");
}
I use this same model in flash with the arp and arpx components and it
works very well. I'm not a big fan of event bubbling, it may work but I
don't really like it, its a personal thing :)
if you don't want to pull in the cairngorm swc you can create your own
central event dispatcher, its pretty easy, here is one I used before I
used cairngorm...
ackage com.bluetubeinteractive.control
{
import flash.events.EventDispatcher;
import flash.events.Event;
public class SystemController extends EventDispatcher
{
private static var _instance:SystemController = null;
private var _mainContainer:DisplayObjectContainer;
public function SystemController()
{
if (_instance == null)
_instance = this;
}
public static function getInstance():SystemController
{
if (_instance == null)
_instance = new SystemController();
return _instance;
}
public function dispatchEvent(event:Event):Boolean
{
trace("dispatching event " + new Date().toTimeString());
return super.dispatchEvent(event);
}
}
}
obviously remove the trace once your are rolling with it..
Cheers,
Grant.
...........................................
> b l u e t u b e i n t e r a c t i v e.
.: grant davies
.: 404.428.6839 (c)
.: 708-983-1577 (F)
> [EMAIL PROTECTED]
> http://www.bluetube.com/bti <http://www.bluetube.com/bti>
> A Tribal Chicken Designs Affiliate <http://www.tribalchicken.com/>
________________________________
From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Paul J DeCoursey
Sent: Thursday, February 22, 2007 3:35 PM
To: [email protected]
Subject: [flexcoders] Problems with EventDispatching
I have some classes that are EventDispatcher but not DisplayObjects. I
have maybe 10 or 15 of these classes and a few of them will not bubble
events to the SystemManager. I have created the Events to bubble but
they will not. If I listen on the object I receive them. My problem is
the Objects I want to receive the events on don't know about the Objects
that dispatch them and I don't want them to know about them. Has anyone
had a problem like this?
Paul
<<attachment: small.jpg>>

