Actionscript鼠标事件问题
我正在尝试在影片剪辑对象上实现以下控制。当鼠标指针位于对象上方并且单击鼠标左键并保持单击状态时,与影片剪辑对象重叠的蒙版将开始消失。我尝试了 MouseEvent.DOWN 等,但没有成功实现此功能。也许我错过了什么。我可以通过标准鼠标事件类型来实现这一点还是必须以其他方式实现? 另外,是否可以通过减少 alpha 属性来淡出蒙版,从而真正使鼠标指针下方的像素消失?
i am trying to implement the following control on a movieclip object. When the mouse pointer is over the object and if the left mouse button is clicked and stays clicked then a mask that overlaps the movieclip object is starting to disappear. I tried the MouseEvent.DOWN, etc but i did not succeed to implement this functionality. Probably i miss something. Can i achieve this through standard mouse events types or do i have to implement it another way?
Also is it possible instead to fade out the mask by reducing the alpha attribute, to actually make dissappear the pixel(s) that under the mouse pointer ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
MouseEvent.MOUSE_DOWN
/Mouse.MOUSE_UP
确实是要使用的事件,因此您的代码中最有可能出现问题。由于对象重叠,经常会发生此事件不会被触发的情况,我怀疑在这种情况下它可能是蒙版。如果是这种情况,您只需使用
mouseEnabled = false
禁用阻塞性显示对象上的 mouseEvents。示例:
有关光标下像素的一些快速提示:
您可以使用 位图 对象。
可以使用 mouseX、mouseY 检索像素坐标(请注意,位图对象不会分派鼠标事件,因此您需要将其添加到精灵中以用作包装器)。
您可以通过 检索像素实际颜色/alpha getPixel32 并通过 setPixel32 修改它。
如果您遇到麻烦,我建议您为此提出一个单独的问题。
希望有帮助,
T。
MouseEvent.MOUSE_DOWN
/Mouse.MOUSE_UP
are indeed the events to use so there most be a problem in your code.It often happens this event doesn't get triggered because of objects overlapping and I suspect in this case it might be the mask. If this is the case you can simply disabling mouseEvents on the obstructive displayObjects with
mouseEnabled = false
.Example :
A few quick hints regarding the pixel under the cursor :
You can do it with a Bitmap object.
The pixel coordinates can be retrieved with mouseX, mouseY (note that bitmap objects don't dispatch mouse events so you need to add it to a sprite to use as a wrapper).
You can retrieve the pixels actual color/alpha by getPixel32 and modify it by setPixel32.
If you are having troubles I suggest you open a separate question for that.
Hope it helps,
T.