5 Replies Latest reply on Apr 19, 2007 10:30 AM by rayess

    Is this a bug or what?

    rayess
      Hi,
      Have you ever tried to pass integers from a popup to its parent after manipulating it?
      unfortunately the integer keeps its value in the parent without applying the changes that happened inside the popup.

      So...
      Is this a bug or a problem with my code?
        • 1. Re: Is this a bug or what?
          jlingwai Level 1
          what does you code look like???

          when you change the value in the pop are you also changing the value in the parent?
          Ex.
          Pop-up:
          public function changeVal(val:int):void{
          parentApplication.intTest = val;
          }
          • 2. Re: Is this a bug or what?
            babo_ya Level 3
            try .. parentDocument.intTest or if it doesn't work try to create a custom event and addEventListener for the pop up and when event is dispatch update the value.
            • 3. Re: Is this a bug or what?
              rayess Level 1
              Actually I passed two variables from the parent to the popup, one is an array, and the seconed is an integer.
              When changing the array inside the popup and adding new elements to it without referencing it by using the parentDocument.{the array}, the manipulation was successful and the parent kept the changes. But when doing the same with the integer, the parent didn't accept the change and kept its value without changing, so I had to reference the integer using the parentDocument.{the integer} which is the opposite of what is described in the flex mannual under the topic of "passing data from and to the popup", and that was the reason of my wonder.

              Do you have any idea of why is that?
              • 4. Re: Is this a bug or what?
                peterent Level 2
                This is a basic issue of scope and value passing. In [nearly?] all modern languages passing scalar values results in a copy of the value while passing complex structures, such as instances of classes and Arrays, is done by reference. Passing scalars is called pass-by-value.

                This is normal and definitely not a bug. What I would do is have the pop-up dispatch a custom event with the new value.
                • 5. Re: Is this a bug or what?
                  rayess Level 1
                  I see.
                  And it also can be done without dispatching an event but referencing the parent integer and have all the actions and manipulations done on this reference inside the popup, is that correct? or dispatching an event is better?