Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4028448
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:13:16+00:00 2026-05-20T11:13:16+00:00

I am having trouble handling a MouseEvent.MOUSE_DOWN on an component with a Image for

  • 0

I am having trouble handling a MouseEvent.MOUSE_DOWN on an component with a Image for a mask in Flex 4.

I have an application as follows:

<?xml version="1.0"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
  xmlns:s="library://ns.adobe.com/flex/spark"
  xmlns:mx="library://ns.adobe.com/flex/mx"
  creationComplete="init()"
  >
  <fx:Script>
  <![CDATA[
  import spark.core.MaskType;

  public function init():void {

    manager.addEventListener( MouseEvent.MOUSE_DOWN, handleMouseDown );
  }

  public function handleMouseDown(e:MouseEvent):void {
    trace( e.target )
  }

  ]]>
  </fx:Script>

  <s:Group id="manager" width="500" height="500">
    <s:Group id="layer" mouseChildren="false" x="220">
      <s:Group id="content" maskType="{MaskType.ALPHA}" cacheAsBitmap="true">
        <s:Rect width="338" height="162">
          <s:fill>
            <s:SolidColor color="0xDDAAAA" />
          </s:fill>
        </s:Rect>
        <s:mask>
          <s:Group>
            <mx:Image 
              source="http://www.wpclipart.com/signs_symbol/alphabets_numbers/3D_text_T.png"
              cacheAsBitmap="true" 
              />
          </s:Group>
        </s:mask>
      </s:Group>
    </s:Group>
  </s:Group>
</s:Application>

If you run this, you will notice that if you click on the left side of the image (on the “3”), the trace correctly indicates that “layer” got clicked. However, if you click on the right side of the image (on the “D”) you’ll see that “manager” got clicked instead of “layer”, which is wrong. If you click anywhere on the “layer” that is past 338px (the mask size), the mouse event does not seem to make it to the layer object.

If I remove the “x” offset on “layer”, the whole layer works as expected, but as soon as I offset, anything past the width of the mask (338px) seems to not be captured properly, like if the mask wasn’t offset. The strange thing is that if you click to the left of the image once it has been offset, you do get “manager”, which means that the layer (and mask) did get moved.

Here’s what I mean, with no offset, clicking on the green area returns “layer”, clicking on the blue area returns “manager”, which is the expected behaviour. See image

If I offset the layer by 220, the areas behave like this image

Sorry I can’t embed the images here, but I don’t have enough reputation 🙁

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T11:13:17+00:00Added an answer on May 20, 2026 at 11:13 am

    Figured it out.

    Apparently the problem is that the Image that is used as the mask needs to be added to the display list before it gets set as the mask or this erratic behaviour happens. This is what the code looks like now and it’s working:

    <?xml version="1.0"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
      xmlns:s="library://ns.adobe.com/flex/spark"
      xmlns:mx="library://ns.adobe.com/flex/mx"
      creationComplete="init()"
      >
      <fx:Script>
      <![CDATA[
      import spark.core.MaskType;
    
      public function init():void {
    
        manager.addEventListener( MouseEvent.MOUSE_DOWN, handleMouseDown );
      }
    
      public function handleMouseDown(e:MouseEvent):void {
        trace( e.target.id )
      }
    
      ]]>
      </fx:Script>
    
      <s:Group id="manager" width="500" height="500">
        <s:Group id="layer" mouseChildren="false" x="100" mouseEnabledWhereTransparent="false">
          <s:Group id="content" mask="{maskImage}" maskType="{MaskType.ALPHA}" cacheAsBitmap="true">
            <s:Rect width="338" height="162">
              <s:fill>
                <s:SolidColor color="0xDDAAAA" />
              </s:fill>
            </s:Rect>
          </s:Group>
          <mx:Image id="maskImage"
            source="http://www.wpclipart.com/signs_symbol/alphabets_numbers/3D_text_T.png"
            cacheAsBitmap="true" 
            />
        </s:Group>
      </s:Group>
    </s:Application>
    

    Also of note is that the maskImage is a child of layer and not a child of content. Setting it as a child of the latter results in the same incorrect behaviour as before.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application that's having some trouble handling multi-processor systems. It's not an
I'm having some trouble with my error handling in my ASP.NET MVC 2 application.
I have a public repository on github that I'm having trouble handling pull requests
I'm having trouble handling the scenario whereby an event is being raised to a
A poorly-written back-end system we interface with is having trouble with handling the load
Having trouble linking the Stomp.framework into an iPhone SDK application. http://code.google.com/p/stompframework/ I follow the
Having Trouble with Entity Framework. I have been populating EntityReferences with an EntityKey inorder
I having trouble in dividing the HTML frames. I have been using the following
I'm having trouble handling IDs of my databse tables using OpenJPA and HSQLdb. I
I'm building a simple interpreter in python and I'm having trouble handling differing numbers

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.