1 Reply Latest reply on Mar 31, 2011 7:34 AM by UbuntuPenguin

    Flex recreates Image inside HDividedBox and loses event listener.


      I have a scenario where I add a few of the same component (a container to hold a object) which is derived from mx Panel to a HDividedBox. The layout is set to "absolute".


          public class ObjectContainer extends Panel
             this.layout = "absolute";
             //rest of the code


      Now the HDividedBox nicely displays the containers with a divider in between each container.


      In the containers creation complete event, I add a image which I want basically work as a button to display a context menu. I add it to the top right corner. So I add the image, and add a action listener for the click event


          myButton = new Image();               
          myButton.source = myDownImageClass;
          myButton.addEventListener(MouseEvent.CLICK, showObjectContainerMethods);
          myButton.right = 5
          myButton.top = 5;



      Now this works fine too.


      The issue comes when an object is added to the container which is bigger than the container. The image (button) gets removed from the stage and then added back. (Confirmed it by listening to `ADDED_TO_STAGE` and `REMOVED_FROM_STAGE` events). The image visually does not appear to be removed and added back though.


      BUT, the action listener wont fire anymore after the image is added back! What could be the cause and any potential fixes?


      I tried adding the actionListener back in the added event, but still it wont work