调整影片剪辑的大小而不弄乱鼠标坐标
我该怎么做?我有一个搜索栏,我正在对其进行改造以使用 FLVPlayback 调整大小。现在,当您单击搜索栏时,它会获取 mouseX,并将其除以搜索栏的长度,以便知道它应该搜索的百分比。
我的问题是,现在我动态设置搜索影片剪辑的宽度,宽度返回我设置的宽度,而鼠标事件返回位置,就好像它仍然是库中的原始宽度一样。
我该如何解决这个问题?
How do I do this? I have a seekbar which I'm retrofitting to resize with the FLVPlayback. Right now it gets the mouseX when you click the seekbar, and divides that by the length of the seekbar in order to know what percentage it should seek to.
My problem is that now that I'm dynamically setting the width of the seek movieclip the width returns the width I set, while the mouse event returns the position as if it was still the original width it has in the library.
How do I get around this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只需根据您的原始宽度进行缩放即可。假设您有一个 100 像素宽的栏,只需执行:
无论搜索栏的当前宽度如何,这都会为您提供点击的百分比。
漂亮又简单,不需要时髦的坐标空间转换。
Just scale against the original width you had. Say that you've got a 100px wide bar, just go:
This will give you the percentage clicked at regardless the current width of the seekbar.
Nice and easy and no funky coord space conversions needed.
MouseEvent 对象具有 stageX 和 stageY 属性 - 您只需将这些值偏移剪辑的位置即可设置。
The MouseEvent object has a stageX and stageY property - you just need to offset those values by the position of the clip and you should be set.