2 Replies Latest reply on Jan 28, 2011 6:51 AM by pauland

    Is it possible that event can bubble down?

    krishnamrajgoud Level 1

      Hi,


           I Know, Event only Bubbles up, but is it possible that event can bubble down. I have a requirement where my child components need to request an Event to Parent Component and on request parent has to notify/pass the data to the child container components, which i thought would be possible with two events, one from child to parent and other from parent to child. but event always bubble up only. so is there any work around apart from passing the childern the data manually via public properties, which will make it reduntant, as i have lots of child components to this parent.


      Regards,

      Krishnam Raju Goud.G

        • 1. Re: Is it possible that event can bubble down?
          Lee Burrows Level 4

          hi

           

          the only way to pass events (or any other objects) to children is as you suggest - by passing to public properties (or passing in via the constructor).

           

          however, there are some technqiues that can reduce the effort - try searching for "dependency injection" or "chain of responsibility design pattern"

          1 person found this helpful
          • 2. Re: Is it possible that event can bubble down?
            pauland Level 4

            It's possible to use a central controller singleton to listen for events (some people use the Application itself for this purpose) so that instead of the child listening for the events, the child attaches a listener to the controller for an event and then handles the event.

             

            I have the feeling though that your application is badly architected. If you use the MVC pattern your views should be updated by changes to the underlying model, not by changes in another part of the view.

             

            Store your application data in the model. Changes to the model should then be notified to the controller which then instigates a view change. In Flex we have a binding mechanism which allows views to bind to the model and have changes take place in the view. When the user interacts with the view in a way that should affect the model, the view should inform the controller via an event so that it can instigate a change to the model.

             

            Naturally, this is all a bit much to explain in one forum message. Google Flex MVC.

             

            The important thing to understand is that building in dependencies between parts of the view is not the right way to go.

             

            Paul

            1 person found this helpful