2 Replies Latest reply on Dec 11, 2009 3:29 PM by PeakDigital

    Variable being changed, can't see how?

    PeakDigital Level 1

      I have been going crazy for the past few hours trying to figure out how the value of one of my variables is changing.  I am working on an editable Tree component. The code I am writing is to detect if a change has been made to the tree node, and take action if it has.

       

      My concept is to capture the contents of the node when the item receives focus, then compare that to the contents when it loses focus.

       

      Here is my code that runs upon event ListEvent.ITEM_FOCUS_IN

      private function captureInitialNodeValue(event:ListEvent):void
                  {
                  _xmlTreeNodeContents=XML(event.itemRenderer.data);
                  }    
      

       

      and the function that runs upon event ListEvent.ITEM_FOCUS_OUT

       

      private function submitNodeEdit(event:ListEvent):void
            {
            if(event.itemRenderer.data != _xmlTreeNodeContents)
              {//item has changed. Upload new values.               
              ... do stuff here...
              }
            }
      

       

      It seems straightforward, but every time I step through and debug, when the focus_out event runs, my _xmlTreeNodeContents always contains the new value, not the value from when the tree item received focus.

       

      Can anyone help me figure out what could be causing this? I have gone through my code and made sure there are no other references to the _xmlTreeNodeContents variable anywhere in the class. I have tried placing trace commands in each function and it never traces anything but the original value, yet the changed value is what gets compared in the second function.

       

      Thanks for your help.

      Paul