3

I am creating a photo editor app where, at some point, the photo you edit is supposed to be dropped between two layers of DisplayObjects (a background image and an image mask.)

There is a problem, though. When the image you are editing is dropped between the background and the image mask layers, it becomes unclickable, and therefore gets stuck there, with no chance of dragging it again. (The photo editor uses TransformManager library.)

I am looking for a way to allow you to select the image you are editing no matter if there is another DisplayObject on top of it. And that probably means finding some way to click through the image mask.

Is there a way to do that?

I tried setting mouseChildren = false on imageMask, but that didn't have the desired effect.

Many thanks.

picardo
  • 24,530
  • 33
  • 104
  • 151

7 Answers7

11

I had similar problems and I managed to solve it by using both

 displayobject.mouseChildren = false;  

and

displayobject.mouseEnabled = false;  

on the object that you want to click through.

Poppe76
  • 394
  • 3
  • 14
9

How about this?

mask.mouseEnabled = false;

Amarghosh
  • 58,710
  • 11
  • 92
  • 121
  • This solution is better than the selected answer if you do not need to control the mask with the mouse. – avanderw May 06 '13 at 08:51
2

You can always attach a Mouse Click listener to the container, and then either use GetObjectsUnderPoint and check for your object or do a hit test and see if the mouse position is over your intended object.

The hit test would look something like this !this.YourPhoto.hitTestPoint(stage.mouseX, stage.mouseY, false)

b

WillyCornbread
  • 837
  • 1
  • 12
  • 21
1

If I understand your problem, this handy class should solve it: http://www.mosessupposes.com/utilities/InteractivePNG.html

Tim Scollick
  • 1,242
  • 1
  • 16
  • 17
0

I think I stumbled upon similar problem, although in as2.

In flash when you position movie clip over movie clip, and the movie clip on the top has any mouse events implemented, it captures all mouse events so they never reach occluded movie clip.

The solution is not to have any mouse events for the top movie clip and have the movie clip positioned at the bottom capture mouse event and redirect some of them to the top movie clip (you can check mouse position with hitTest to determine if they should be redirected).

Kamil Szot
  • 17,436
  • 6
  • 62
  • 65
0

Take a look at what senocular does here, specifically in the handleUpdate method. Basically: getting a list of everything under the mousePoint to find your object.

jedierikb
  • 12,752
  • 22
  • 95
  • 166
0

i had a strange bug i used;

movieClip.mouseEnabled = false;

but wasn't working for some reason.. was driving me crazy!! as i have used it so many times before. tried lots of different things nothing worked then i deleted the MovieClip and the created a new one and worked.. so the MovieClip's contents must have been corrupt or something as it had a old dynamic Text Area box embedded within the MovieClip.

hope this helps someone out there..

K-G
  • 2,799
  • 4
  • 26
  • 42