2 Replies Latest reply on Aug 13, 2007 6:33 AM by Ukie_239

    Updating Between Components

    Ukie_239 Level 1
      I have a component inside a component that sites on the main application. ( So third level down) This component contains the total cart items and total value.

      I have another component which sits inside a component which is used to Add Items to a cart. When the button is pressed, a shared object is updated. When that shared object is updated, I want the component listed at the beginning to update via a listener. ( i can do it by parentDocument.parentDocument ..... currently)

      If the shared object is called cartItems, how can I can get component at the top to update when the shared object is updated
        • 1. Re: Updating Between Components
          ntsiii Level 3
          Unless you need to persist data across appliation sessions(ie, closing the Flex app) you don't need SharedObject (or are you using that term more generally)

          You are on the right track with events. A key idea in this situation is "bubbling" . when you dispatch an event tht bubbles, you can listen for it anywhere in the parent document chain:
          dispatchEvnet(new Event("myEvnet",true); //the "true" makes it bubble

          Then, say at the top, application level:

          • 2. Re: Updating Between Components
            Ukie_239 Level 1
            OK so on my main app, i have:
            public function init():void {
            this.addEventListener(MouseEvent.MOUSE_UP, itemMenu.menuItem, true);

            On my menuItem Component, I have
            public function init():void {
            cell.dispatchEvent(new Event("menuItem", true, true));
            public function menuItem (e:Event):void {
            Alert.show (e.eventPhase + " - " + e.currentTarget.id);

            both init functions are called at the init of the application. What I want to be able to do now it get the event information of the component instead of the parent application. How can I do that?