1 Reply Latest reply on Aug 19, 2008 6:58 AM by Newsgroup_User

    Pushing Events to childs

    Nani.Raj Level 1
      Is there a way that parent will push an event to its child
      for example
      <Application>
      <Component1>
      this.addEventListner( SampleEvent.EVENT, onSampleEvent );
      - - - -
      - - - -
      function onSampleEvent( event:SampleEvent ) : void {

      }
      <ChildComponent1>
      this.addEventListner( SampleEvent.EVENT, onSampleEvent );
      - - - -
      - - - -
      function onSampleEvent( event:SampleEvent ) : void {
      }
      </ChildComponent1>
      </Component1>

      <Component2>
      <Button click="this.dispatchEvent( new SampleEvent() )" />
      </Component2>
      this.addEventListner( SampleEvent.EVENT, onSampleEvent );
      - - - -
      - - - -
      function onSampleEvent( event:SampleEvent ) : void {
      }
      </Application>
      when i click button in the Component2 i need the SampleEvent in Componet1 and ChildComponent1.

      any help?
      Thanks
        • 1. Re: Pushing Events to childs
          Level 7

          "n@ni" <webforumsuser@macromedia.com> wrote in message
          news:g8dr7r$aam$1@forums.macromedia.com...
          > Is there a way that parent will push an event to its child
          > for example
          > <Application>
          > <Component1>
          > this.addEventListner( SampleEvent.EVENT, onSampleEvent );
          > - - - -
          > - - - -
          > function onSampleEvent( event:SampleEvent ) : void {
          >
          > }
          > <ChildComponent1>
          > this.addEventListner( SampleEvent.EVENT, onSampleEvent );
          > - - - -
          > - - - -
          > function onSampleEvent( event:SampleEvent ) : void {
          > }
          > </ChildComponent1>
          > </Component1>
          >
          > <Component2>
          > <Button click="this.dispatchEvent( new SampleEvent() )" />
          > </Component2>
          > this.addEventListner( SampleEvent.EVENT, onSampleEvent );
          > - - - -
          > - - - -
          > function onSampleEvent( event:SampleEvent ) : void {
          > }
          > </Application>
          > when i click button in the Component2 i need the SampleEvent in Componet1
          > and
          > ChildComponent1.

          The typical way to do it is to bind the child components to a data model and
          have the children change based on the change in data:

          http://www.adobe.com/devnet/flex/articles/graduating_pt2.html
          http://www.adobe.com/devnet/flex/articles/loose_coupling.html