I am having troubles when dispatching and listening to events
in my application, can i dispatch events from an object that is not
on the display list and have a display object to listen to that
I am doing the following, i have a DataGrid componente
listening for an event that it is dispatched from a non visual
object; the event contains info about the new dataProvider for the
DataGrid, here is the code:
Component with the DataGrid <mx:TitleWindow xmlns:mx="
layout="vertical" width="550" height="600"
pickListResult.dataProvider = event.newDataProvider;
public class GetTiposFacultadesCommand extends
EventDispatcher implements Command, Responder
public function execute(event:CairngormEvent):void
var delegate:BusinessDelegate = new BusinessDelegate(this);
public function onResult(event:* = null):void
var _dataModelEvent:DataProviderChangeEvent = new
DataProviderChangeEvent('newDataProvider', false, false);
_dataModelEvent.newDataProvider = event.result.toArray();
public function onFault(event:* = null):void
The thing is that the DataGrid never receives the event, i
have no idea why it's not working. Can anyone help me out???
In your code, you're listening
to the grid for the "newDataProvider" event. That's wrong.
The grid never dispatches a "newDataProvider" event. You need to
listen to the dispatcher of the event, namely the instance of
GetTiposFacultadesCommand that you've declared somewhere.
The point is that i dont want to have to pass the instance of
the GetTiposFacultadesCommand to catch the event. The point is to
send an event anywhere and be able to catch it anywhere in the
I found a solution to this, i created my own EventDispatcher
object as a singleton in the application, whenever i want to send
an event and be able to catch it anywhere, i get the instance of
this object and have it to send the event, wherever i want to catch
it i get the instance of this object and have it to listen to it,
in other words the EventDispatcher object i coded is a generic
object that will send and receive the events, allowing others to
get this instance and do something about the event.
This object has a
getInstance() method that returns the instance of this
object, remember that this is a singleton so there's only one
instance of it in the whole application, any object can get this
instance and send/receive an event.