Views listening for events from the global EventDispatcher

View: New views
2 Messages — Rating Filter:   Alert me  

Views listening for events from the global EventDispatcher

by Marcelo de Moraes Serpa :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello list,

I've got the classic pixlib MVC architecture.

I've got a command that is called at the init of the application to load some data from a XML. The event, listed in the EventList is called LOAD_XML. In order to perform some user interface changes, I want some views to listen for this event. However, I'm not sure where I should add the views as listeners for the global EventDispatcher. For now, I'm doing this in the main Application's class constructor:

   public function Application ( target )
   {
       (...)
       var vBottomBar:ViewBottomBar = new ViewBottomBar(this.bottom_bar_mc);
       var vContent:ViewContent = new ViewContent(this.content_mc );
  
       EventDispatcher.addListener(vBottomBar);
       EventDispatcher.addListener(vContent);

       EventDispatcher.dispatchEvent( new BasicEvent( EventList.LOAD_XML ) );


And then I implement a onLoadXml in each of the views. It works fine and seems to be a good design. I could also get a reference for each view in the LoadXML command and call the method directly. What do you think?

Marcelo.




_______________________________________________
Pixlib mailing list
Pixlib@...
http://osflash.org/mailman/listinfo/pixlib_osflash.org

Re: Views listening for events from the global EventDispatcher

by dev-17 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Putting the config data in a model and updating that from the loadxml
command's onResult would work too.

> Hello list,
>
> I've got the classic pixlib MVC architecture.
>
> I've got a command that is called at the init of the application to load
> some data from a XML. The event, listed in the EventList is called
> LOAD_XML.
> In order to perform some user interface changes, I want some views to
> listen
> for this event. However, I'm not sure where I should add the views as
> listeners for the global EventDispatcher. For now, I'm doing this in the
> main Application's class constructor:
>
>    public function Application ( target )
>    {
>        (...)
>        var vBottomBar:ViewBottomBar = new
> ViewBottomBar(this.bottom_bar_mc);
>        var vContent:ViewContent = new ViewContent(this.content_mc);
>
>        EventDispatcher.addListener(vBottomBar);
>        EventDispatcher.addListener(vContent);
>
>        EventDispatcher.dispatchEvent( new BasicEvent( EventList.LOAD_XML )
> );
>
>
> And then I implement a onLoadXml in each of the views. It works fine and
> seems to be a good design. I could also get a reference for each view in
> the
> LoadXML command and call the method directly. What do you think?
>
> Marcelo.
> _______________________________________________
> Pixlib mailing list
> Pixlib@...
> http://osflash.org/mailman/listinfo/pixlib_osflash.org
>


_______________________________________________
Pixlib mailing list
Pixlib@...
http://osflash.org/mailman/listinfo/pixlib_osflash.org