4 Replies Latest reply on Nov 2, 2009 7:44 AM by dj_coding

    Need help with traping mouse Event

    Zane_Zhou
      Hello

      I have a problem.

      I have a button which is created behind a image component. look like this

      <mx:Canvas x="0" y="0" width="500" height="400" borderStyle="solid">

      <mx:Button id="mybtn" x="10" y="10" label="Button" width="72" click="trace('sss')"/>

      <mx:Image x="0" y="0" width="500" height="400" source="../assets/help_numbers.png" />

      </mx:Canvas>



      What I want to do is to ask the Image to ignore all user interaction and pass those interaction to the Button. In the other word, the Image
      should not catch any of the user interaction and acts like totally transparent in terms of user mouse click or mouse over action, ant it should
      let the Button catch those actions.

      Any idea?
        • 1. Re: Need help with traping mouse Event
          EvolvedDSM Level 2
          Not sure if you know this, but you can set a click attribute to your image.

          <mx:Image x="0" y="0" width="500" height="400" source="../assets/help_numbers.png" click="trace('sss')" />

          So, when people click on the picture, they are actually clicking the picture and not some button they don't see. Does this help? Maybe I'm missing the point of a button behind a picture...
          • 2. Re: Need help with traping mouse Event
            Zane_Zhou Level 1
            thank you for posting.

            The Button is totaly behind the Image. If the Image is transparent, you can see through the Image and see the button.

            I know how to trap the click on the Image by adding the click attribute. However, that's not what I want.
            I would like the Image to ignore the click and the button behind it should trap the click. In that way, the
            Image should literaly be transparent in terms of both visibility and user interaction.

            Thanks


            • 3. Re: Need help with traping mouse Event
              EvolvedDSM Level 2
              Well if the image is transparent visually, then all you will see is the button behind it, which defeats the purpose of having an image component in the first place. Transparency is clear, unobstructed -- such as a glass window. Maybe you didn't mean to say it should be transparent visibly, but that I cannot assume.

              I'm still curious as to the reasoning behind what you are trying to accomplish. I'd like to know just in case there's a better way to handle what you wish to do. As far as I know, interaction can only come from objects at the top level. So having a button on a level below the image is no different than if there wasn't a button at all.
              • 4. Re: Need help with traping mouse Event
                dj_coding

                I was looking for this too. So for the next guy who needs it, you set the mouseEnabled of the top clip to false. If the top clip has child objects, you'll have to set it for them, or use mouseChildren.