I currently working on a jigsaw puzzle game using Flex 4. I have created a puzzle object which is simply a group containing all of my pieces. When the puzzle object is created it dynamically create all of my pieces using as3.
Where my problem occurs is in moving the pieces around the puzzle area. My pieces are kind of complex. The tree goes BorderContainer > Group > Image. This format is important for the pieces to contain the correct portion of the image. I noticed through some debugging I have already done that, somewhat obviously, clicking the image for a piece generates an image click event, not a border container click event. This is important because when I move the pieces I want to move the border container.
So given that the click event target would become the image I click on, any suggestions to access the border container in the click event. Again the end goal is to move the border container.
Fyi: I have already tried the phrase "event.target.parent.parent", the first parent being the group, the second the border container. but as3 doesnt understand the second parent reference, so it returns the group. So I cannot reference the border container to use to startDrag function. Also, this means i cannot move the selected piece to the front of the UI.
Thanks for any replies in advance .
Try setting mouseChildren=true and mouseEnabled=true on the BorderContainer,
and mouseEnabled=false on the Group and maybe on the Image as well.
Thanks for the help, i completely forgot about mouse properties. I ended up setting mouseFocusEnabled = false for my group and image and true for the border. This hands any click events to the border, so then i can reference with the target keyword in the mouse event.