5 Replies Latest reply on Apr 10, 2008 8:46 AM by jonny go to school

    Canvas children and mouseOver

    jonny go to school
      Simply put, I have a repeating canvas that contains buttons, an image, and a text field. When the user rolls their mouseOver the canvas, a child canvas becomes visible with buttons inside of it. Works great when you make sure that the mouse stays only over true canvas area and not over a child inside of the canvas. If it falls over a child, it fires the mouseOut and the buttons become invisible. Essentially, you can't click on the buttons because they are a child and the mouseOut goes off, making them invisible! How can I keep the mouseOver alive, even over a child?
      Thanks!
        • 1. Re: Canvas children and mouseOver
          jonny go to school Level 1
          Sorry, should read "issues mouseOut firing while over a child"
          • 2. Re: Canvas children and mouseOver
            Gregory Lafrance Level 6
            You could listen for mouseOver events in the Canvas, and check the parent of the event target. This way you will also respond to events cascading down to the children of the Canvas. My response ignores the analysis and code reworking you would do in this case, but you just have to work it out.
            • 3. Re: Canvas children and mouseOver
              jonny go to school Level 1
              Thanks for the response. I will look into it more closely. I am an old Lingo programmer so I have dealt with this kinda stuff before, it is just the language that gets me. "check the parent of the event" Do you mean that somehow I can make the event trigger/or ignore on anyone that shares the same parent, in this case the canvas? I guess I am not sure on how to "check the parent of the event"

              Thanks again for your help.
              http://ctl.iupui.edu/common/FlexItems/ResourcesCTL/bin/
              • 4. Re: Canvas children and mouseOver
                Gregory Lafrance Level 6
                check the parent of the event "target", not the parent of the event.

                In Flex, events can possibly participate in three phases:

                1) cascading phase as the event goes from the top of the display list through all parents of the control that dispatched the event.

                2) targeting phase, as the event goes through the target, the control that dispatched the event.

                3) bubbling phase as the event goes back up the display list through parents of the control that dispatched the event.

                - not all events bubble
                - you may need to add an event listener twice, and have the arg to addEventListener for bubbling to true and then false if you want to listen during cascading and bubbling phases.

                Now you are probably confused, so ignore some of what I said, and concentrate on listening to mouseOver events in the Cnavas, and then when the event handler is called, examine the target and possibly currentTarget properties of the event object to see if it is the child of the Canvas, and then act as appropriate.
                • 5. Re: Canvas children and mouseOver
                  jonny go to school Level 1
                  I have the issue resolved 95%. If I take everything out of the repeaters and create an eventListener with the following code it works

                  private function nodeOver(event:MouseEvent):void {
                  buttonHolder.visible=true;
                  /* Alert.show("This is happening") */
                  }

                  private function nodeOver1(event:MouseEvent):void {
                  buttonHolder.visible=false;
                  /* Alert.show("This is happening") */
                  }

                  private function createLinkListener():void {
                  loop.addEventListener(MouseEvent.MOUSE_OVER,nodeOver);
                  loop.addEventListener(MouseEvent.MOUSE_OUT,nodeOver1);
                  }

                  This works great because listener calls loop. If loop is involved in the repeater I will have to send the target.instanceIndices to the function. I would think I can figure this out. Thanks for making me think outside of where I was heading with this!
                  Jon