List Info

Thread: Views listening for events from the global EventDispatcher




Views listening for events from the global EventDispatcher
user name
2008-01-15 11:35:33
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.



Re: Views listening for events from the global EventDispatcher
country flaguser name
Romania
2008-01-15 11:55:39
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
> Pixlibosflash.org
> http://osflash.org/mailman/listinfo/pixlib_osflash.org

>


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


[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )