(ActionScript) 使用蒙版更改影片剪辑宽度
有没有一种方法可以通过改变对象的宽度和高度来遮盖影片剪辑?我有一个宽度较大的子影片剪辑,因此在按比例操纵父影片剪辑的宽度、高度和坐标时遇到问题。
我很感激你的帮助。谢谢。
Is there a way to mask a movie clip in a way that alters the width and height of the object? I have a child movie clip that is larger in width so I'm having issues manipulating the width, height and coordinates proportionally of the parent movie clip.
I appreciate the help. Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
Colin Moock 对此主题有一篇很好的文章,其中包括一种通过位图获取可见宽度和高度而不是内容的宽度和高度的繁琐方法:
http://www.moock.org/blog/archives/000292.html
Colin Moock has a good write-up on the subject here, including a kind of cumbersome way to get the visible width and height instead of the width and height of the content, via a bitmap:
http://www.moock.org/blog/archives/000292.html
我在动作脚本中找到了一种简单的方法。
首先为影片剪辑创建一个类,用于保存蒙版和“要蒙版的项目”。
该影片剪辑必须具有与遮罩相同的宽度和高度,以便在不更改影片尺寸的情况下操作内部数据。
为了做到这一点,我只需覆盖它的宽度和高度。
像这样:
}
现在只需将内容添加到 mvContent 电影中;
希望有帮助!
I´ve found a simple way in actionscript.
First create a class for the movieclip that will hold the mask and the "item to be masked".
this movieclip must have the same width and the height of the mask in order to manipulate data inside without change the dimensions of the movie.
in order to do that i simply override the width and height of this.
Something like this:
}
And now is just add contents to the mvContent movie;
Hope it helps!
使用父对象的 _xscale 和 _yscale 属性(而不是 _height 和 _width)可能会有所帮助,因为这些属性不受子对象大小的影响。
因此,如果您的parentClip是50宽x 80高,那么将其大小重新调整为150 x 160
(这是针对AS2的,但代码对于AS3来说是类似的......您的问题并不具体)
It might help to work with the _xscale and _yscale properties of the parent (rather than the _height and _width), since these aren't affected by how big the child object is.
So if your parentClip is 50 wide x 80 high, then to re-size it to 150 x 160 you do
(This is for AS2, but the code would be something similar for AS3... your question wasn't specific)
您还可以获取蒙版本身的尺寸而不是影片剪辑的尺寸。
You could also grab the dimensions of the mask itself rather than the movieclip.