如何动态更改时间线动画蒙版的宽度/位置?

发布于 2024-08-19 05:00:57 字数 365 浏览 3 评论 0原文

我有一个有两层的影片剪辑 - 一个背景影片剪辑,上面是一个蒙版影片剪辑(正如您可能猜到的那样,该层遮盖了第一层)。由于设计的需要,遮罩在时间线上跨 60 帧进行动画处理。

当我在调整浏览器窗口大小时使用 Event.RESIZE 侦听器更改父影片剪辑的宽度时,就会出现问题。引用掩码的任何代码,即

parentMC.contentMask.width = stage.stageWidth; parentMC.contentMask.x = frame.width/2 - frame.contentMask.width/2;

只会导致遮罩动画根本不播放。这个问题有什么解决方案吗(我已经搜索了很多网站,但可能我忽略了一些非常明显的东西)。

非常感谢。

I've got a movieclip with two layers - a background movieclip, and above that, a mask movieclip (as you might guess, this layer is masking the first). Due to design necessity, the mask is animated on the timeline across 60 frames.

The problem arises when I use an Event.RESIZE listener to change the width of the parent movieclip when the browser window is resized. Any code to reference the mask, i.e

parentMC.contentMask.width = stage.stageWidth;
parentMC.contentMask.x = frame.width/2 - frame.contentMask.width/2;

Simply results in the mask animation not playing at all. Are there any solutions to this problem (I have searched numerous sites for this, but it may be I've overlooked something incredibly obvious).

Many thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

<逆流佳人身旁 2024-08-26 05:00:57

你没有忽略任何明显的事情。不幸的是,您无法通过代码影响时间线补间。不过,有一种方法可以解决这个问题。您需要将时间轴补间蒙版放入另一个影片剪辑中。这样做的缺点是您无法再拖动时间线来查看效果。但是,至少这个方法是有效的。如果这没有意义,请告诉我。我用手机打字,所以解释得不够好。

编辑

好的,为了更好地解释一下(现在在计算机上),您需要将补间嵌套在另一个影片剪辑中。因此,您的补间实际上将位于另一个非补间影片剪辑中,并在第一帧处停止。当你想显示补间时,你需要执行类似 mask_mc.play() 的操作。现在您将能够执行 mask_mc.width = 500;... 等操作。

You have not overlooked anything obvious. Unfortunately you just can't affect a timeline tween via code. However there is a way to deal with the issue. You need to put the timeline tweened mask inside another movieclip. The downside to this is that you can no longer scrub the timeline to see the effect. But, at least this approach works. If this doesn't make sense let me know. Typing from my phone so not explaining as good as I probably should.

EDIT

Ok, so to explain a bit better (now at a computer) you need to nest your tween in an additional movieclip. So, your tween will actually be in another non-tweened movieclip with a stop on the first frame. When you want to show your tween you will need to do something like mask_mc.play(). Now you will be able to do things like mask_mc.width = 500;... etc.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文