在 Actionscript 3 中调整对象的宽度而不移动对象

发布于 2025-01-08 14:37:34 字数 339 浏览 0 评论 0原文

我正在尝试对 MovieClip 对象的宽度属性应用补间,但每次它也会更改宽度和位置,而我不希望这样。我想更改一侧的宽度而不更改对象的 x 和 y。

我尝试了这两种方法,但它们给出了相同的结果。

var c:Tween = new Tween(left, "scaleX", Strong.easeOut, 1, 1.5,20,true);
var c:Tween = new Tween(left, "width", Strong.easeOut, 20, 200,20,true);

我认为它是根据影片剪辑的中心应用变换。但我不知道如何改变它。

有什么帮助吗?

I am trying to do a apply a tween for the width property on a MovieClip Object but every time it changes the width and the position too, and I don't want that. I want to change the width going to one side without changing the x and y of the object.

I tried both of thes and they gave the same result.

var c:Tween = new Tween(left, "scaleX", Strong.easeOut, 1, 1.5,20,true);
var c:Tween = new Tween(left, "width", Strong.easeOut, 20, 200,20,true);

I think it is applying the transformation according to a center of the movie clip. but I don't know how it can be changed.

any help ?

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

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

发布评论

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

评论(2

窝囊感情。 2025-01-15 14:37:34

您的问题是您没有正确绘制影片剪辑,并且它的边界框不是从 x,y, 0 开始;

你能做什么

1. 修复影片剪辑,使图形位于 0,0 位置。

或者

2. 将“左”对象放在另一个对象内,位置为 0,0 并按比例缩放。

或者

3.当调整大小动画工作时,您也可以按比例移动x坐标

var c:Tween = new Tween(left, "width", Strong.easeOut, 20, 200,20,true);
var c1:Tween = new Tween(left, "x", Strong.easeOut, left.x, left.x+delta*200/(2*20),20,true);

其中 delta 是影片剪辑中图像的偏移量。

Your problem is fact that you don't draw your movie clip correctly and it's bounding box dont start from x,y, 0;

what you can do

1. fix movie clip to have graphics in 0,0 position.

or

2. put your "left" object inside another object at position 0,0 and than scale.

or

3. you can proportionally move the x coordinate also while re size animation is working

var c:Tween = new Tween(left, "width", Strong.easeOut, 20, 200,20,true);
var c1:Tween = new Tween(left, "x", Strong.easeOut, left.x, left.x+delta*200/(2*20),20,true);

where delta is offeset of your image inside movie clip.

夜司空 2025-01-15 14:37:34

首先,避免使用默认的 Tween 引擎。有更好的替代方案(这是主要原因,默认的 Tween 引擎很长一段时间没有受到平台开发人员的任何关注)。有些可能性可能可以在这里找到,或者通过网络找到。

是的,事实上,该对象在补间宽度时改变位置,表明它的注册点不在相对于该对象的坐标 0 上。解决方案是:

  1. 如果有可能,请更改对象的注册点。也许通过 Flash IDE 或以编程方式放置组件,例如相对于对象的注册点将位于 0。

  2. 每次迭代,将其右移扩展值的一半。

这个小片段解释了,将其转换为补间应该很容易:

this.addEventListener(Event.ENTER_FRAME, _loop);
function _loop(event:Event):void
{
    derp.width += 10; // every iteration makes width 10 px bigger
    derp.x += 5; // 10 / 2 = 5; might want to calculate this dynamically.
}

请记住,只有当注册点位于对象的死点(x 轴上)时,这才有效。

First of, shy away from the default Tween engine. There are way better alternatives for that (that's the main reason, the default Tween engine hasn't received any attention from the platform devs in a long while). Some possibilities may be found here, or over the web.

Yes, the fact, that object changes position, when tweening the width of it, shows that it's registration point is not on coordinate 0 relative to that object. The solutions are:

  1. If you have the possibility, change the object's registration point. Maybe via Flash IDE or programatically lay down components, such as the reg point would be at 0, relative to the object.

  2. Shift it right by half the expansion value, every iteration.

This little snippet explains that, translating it into tweens should be easy:

this.addEventListener(Event.ENTER_FRAME, _loop);
function _loop(event:Event):void
{
    derp.width += 10; // every iteration makes width 10 px bigger
    derp.x += 5; // 10 / 2 = 5; might want to calculate this dynamically.
}

Bear in mind, this only works well, if the registration point is on the dead center (on x axis) on the object.

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