3 Replies Latest reply on Nov 8, 2006 12:53 PM by kglad

    event handling question

    la_gouyn Adobe Employee
      Hi,

      Let's say I have two Images on a Canvas, and they overlap. The images have transparency.
      If the user clicks in a transparent portion of the top Image, I would like for the event to be passed to the Image underneath. (If the click is in an opaque portion of the top image, I want the top image to handle it normally.)

      Is there a preferred way for the mouse event to get passed to this underneath Image, even though it isn't the intended recipient of this event?

      -Allan
        • 1. Re: event handling question
          kglad Adobe Community Professional & MVP
          there shouldn't be any problem. just define mouse handlers for both.
          • 2. Re: event handling question
            la_gouyn Adobe Employee
            Hi,

            Is that true?

            I use the same event listener for both Image objects.

            When I try this with two Image objects and the front one completely overlaps the other -- if I click on the front Image object, I don't get a mouse down event in the Image object behind it. I would expect this behavior (after all, the click was not on the obscurred object). Isn't this expected?

            That said, if I do want to propagate this mouse event to the Image object behind the front Image object (in my example, if the user clicks in a transparent hole in the front object), how would I do that?

            Thanks.
            -Allan
            • 3. Re: event handling question
              kglad Adobe Community Professional & MVP
              i'm not sure what you are doing. but convert both images to movieclips and use onPress handlers.

              that should allow the movieclip at lower depth to receive onPress events when the mouse is over a transparent region of the movieclip at the higher depth and non-transparent region of the movieclip at lower depth.