简体   繁体   中英

How to click through a display object in Flash with AS3?

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.

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.

这个怎么样?

mask.mouseEnabled = false;

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

如果我理解你的问题,这个方便的课程应该解决它: http//www.mosessupposes.com/utilities/InteractivePNG.html

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).

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.

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..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM