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

三世轮回 提交于 2020-01-13 18:54:47

问题


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.


回答1:


How about this?

mask.mouseEnabled = false;




回答2:


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.




回答3:


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




回答4:


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




回答5:


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.




回答6:


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




回答7:


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



来源:https://stackoverflow.com/questions/1365089/how-to-click-through-a-display-object-in-flash-with-as3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!