开发者

How can I dynamically change the width / position of a timeline-animated mask?

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开发者_如何学Go; 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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜