(ActionScript) 使用蒙版更改影片剪辑宽度

发布于 2024-08-24 14:11:04 字数 100 浏览 5 评论 0原文

有没有一种方法可以通过改变对象的宽度和高度来遮盖影片剪辑?我有一个宽度较大的子影片剪辑,因此在按比例操纵父影片剪辑的宽度、高度和坐标时遇到问题。

我很感激你的帮助。谢谢。

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 技术交流群。

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

发布评论

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

评论(4

怀念你的温柔 2024-08-31 14:11:04

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

我不咬妳我踢妳 2024-08-31 14:11:04

我在动作脚本中找到了一种简单的方法。

首先为影片剪辑创建一个类,用于保存蒙版和“要蒙版的项目”。

该影片剪辑必须具有与遮罩相同的宽度和高度,以便在不更改影片尺寸的情况下操作内部数据。

为了做到这一点,我只需覆盖它的宽度和高度。
像这样:

public class MyMaskedItem extends MovieClip
{
   public var mvMask:MovieClip;
   public var mvContent:MovieClip;

   public function MyMaskedItem() { 
      this.mask = mvMask;
   }

   /**
    * Override width and height properties
    */

   override public function get width():Number { return this.mvMask.width; }

   override public function set width(value:Number):void 
   {
      this.mvMask.width = value;
   }


   override public function get height():Number { return this.mvMask.height; }

   override public function set height(value:Number):void 
   {
      this.mvMask.height = value;
   }

}

现在只需将内容添加到 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:

public class MyMaskedItem extends MovieClip
{
   public var mvMask:MovieClip;
   public var mvContent:MovieClip;

   public function MyMaskedItem() { 
      this.mask = mvMask;
   }

   /**
    * Override width and height properties
    */

   override public function get width():Number { return this.mvMask.width; }

   override public function set width(value:Number):void 
   {
      this.mvMask.width = value;
   }


   override public function get height():Number { return this.mvMask.height; }

   override public function set height(value:Number):void 
   {
      this.mvMask.height = value;
   }

}

And now is just add contents to the mvContent movie;

Hope it helps!

メ斷腸人バ 2024-08-31 14:11:04

使用父对象的 _xscale 和 _yscale 属性(而不是 _height 和 _width)可能会有所帮助,因为这些属性不受子对象大小的影响。

因此,如果您的parentClip是50宽x 80高,那么将其大小重新调整为150 x 160

parentClip._xscale=3; parentClip._yscale=2;//still works even after child is added

(这是针对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

parentClip._xscale=3; parentClip._yscale=2;//still works even after child is added

(This is for AS2, but the code would be something similar for AS3... your question wasn't specific)

帅哥哥的热头脑 2024-08-31 14:11:04

您还可以获取蒙版本身的尺寸而不是影片剪辑的尺寸。

You could also grab the dimensions of the mask itself rather than the movieclip.

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