在保持底部 (Y) 位置的同时进行形状​​补间/变换?

发布于 2024-11-17 08:23:47 字数 476 浏览 5 评论 0原文

我正在尝试对火箭发射的影片剪辑进行补间。我希望它在升空前“挤压”,然后在升空时“拉伸”。

当我使用变换工具在时间轴上对此进行补间时,我可以“挤压”火箭,并且火箭的底部保持在“地面”上。这就是我想要的。然而,由于我不会详细说明的原因,我需要在 AS3 中执行此操作,而不是在时间轴上执行此操作。但是,当我使用“高度”补间时,影片剪辑高度会发生变化,但它会在底部收缩/拉伸(锁定在顶部)。

可以用补间类做我想做的事吗?我还需要使用“高度”之外的其他东西吗?

我应该使用变换矩阵吗?如果我使用变换矩阵,我可以对其进行补间吗? (我在变换矩阵方面没有太多经验。)

这是我用于拉伸的补间:

var tweenPlayer1:Tween = new Tween(mc_player, "height", Strong.easeOut, mc_player.height, mc_player.height+100, 2, true);

I'm trying to shape tween a movie clip of a rocket blasting off. I want it to "squash" before liftoff, and then "stretch" as it lifts off.

When I tween this on the timeline with the transform tool, I can "squash" the rocket, and the base of the rocket stays on the "ground". This is what I want. However, for reasons I won't go into, I need to do this in AS3, as opposed to on the timeline. When I use a "height" tween, though, the movieclip height changes, but it shrinks/stretches at the bottom (locked at the top).

Is it possible to do what I want with the tween class? Do I need to use something besides "height"?

Should I use a transform matrix, instead? If I use a transform matrix, can I tween it? (I don't have very much experience with transform matricies.)

Here's the tween I'm using for the stretch:

var tweenPlayer1:Tween = new Tween(mc_player, "height", Strong.easeOut, mc_player.height, mc_player.height+100, 2, true);

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

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

发布评论

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

评论(3

银河中√捞星星 2024-11-24 08:23:47

可能有更好的方法来处理startingYandHeight,但这对你有用

import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;

var startingYandHeight:Number = mc_player.y + mc_player.height;

var myTween:Tween = new Tween(mc_player, "height", Strong.easeOut, mc_player.height, mc_player.height + 100, 2, true);
myTween.addEventListener( TweenEvent.MOTION_CHANGE, onChange);

function onChange( e:TweenEvent ):void{
    mc_player.y = startingYandHeight - mc_player.height;
}

There probably is a better way to handle startingYandHeight but this will work for you

import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;

var startingYandHeight:Number = mc_player.y + mc_player.height;

var myTween:Tween = new Tween(mc_player, "height", Strong.easeOut, mc_player.height, mc_player.height + 100, 2, true);
myTween.addEventListener( TweenEvent.MOTION_CHANGE, onChange);

function onChange( e:TweenEvent ):void{
    mc_player.y = startingYandHeight - mc_player.height;
}
抱猫软卧 2024-11-24 08:23:47

问题可能在于您将图形锚定在 FLA 中的影片剪辑对象内的位置。如果您调整图形使其底部对齐,例如影片剪辑内部的graphic.y = -graphic.height,则Y轴上的缩放应该只是从底部而不是从顶部推动图形。

The issue probably lies with the where you have the graphic anchored inside of your movieclip object in your FLA. If you adjusted the graphic so that is was bottom justified, for example graphic.y = -graphic.height inside of the movieclip, scaling on the Y axis should simply push the graphic from the bottom and not from the top.

み青杉依旧 2024-11-24 08:23:47

正如我上面所描述的,这是另一种方法。这与更改注册点具有相同的效果,而无需处理子组件和层的麻烦。

基于我在这里找到的教程:http://theflashconnection。 com/content/how-to-change-registration-point-as3#viewSource

var heightChange:int = 200;

setRegPoint(mc_player, 0, mc_player.height);

var myTween:Tween = new Tween(mc_player,"height",Strong.easeOut,mc_player.height,mc_player.height - heightChange,2,true);

function setRegPoint(obj:DisplayObjectContainer, newX:Number, newY:Number):void {
    //get the bounds of the object and the location 
    //of the current registration point in relation
    //to the upper left corner of the graphical content
    //note: this is a PSEUDO currentRegX and currentRegY, as the 
    //registration point of a display object is ALWAYS (0, 0):
    var bounds:Rectangle = obj.getBounds(obj.parent);
    var currentRegX:Number = obj.x - bounds.left;
    var currentRegY:Number = obj.y - bounds.top;

    var xOffset:Number = newX - currentRegX;
    var yOffset:Number = newY - currentRegY;
    //shift the object to its new location--
    //this will put it back in the same position
    //where it started (that is, VISUALLY anyway):
    obj.x += xOffset;
    obj.y += yOffset;

    //shift all the children the same amount,
    //but in the opposite direction
    for(var i:int = 0; i < obj.numChildren; i++) {
        obj.getChildAt(i).x -= xOffset;
        obj.getChildAt(i).y -= yOffset;
    }
}

Here's another approach, as I described, above. This has the same effect as changing the registration point without the headache of dealing with child components and layers.

Based on the tutorial that I found here: http://theflashconnection.com/content/how-to-change-registration-point-as3#viewSource

var heightChange:int = 200;

setRegPoint(mc_player, 0, mc_player.height);

var myTween:Tween = new Tween(mc_player,"height",Strong.easeOut,mc_player.height,mc_player.height - heightChange,2,true);

function setRegPoint(obj:DisplayObjectContainer, newX:Number, newY:Number):void {
    //get the bounds of the object and the location 
    //of the current registration point in relation
    //to the upper left corner of the graphical content
    //note: this is a PSEUDO currentRegX and currentRegY, as the 
    //registration point of a display object is ALWAYS (0, 0):
    var bounds:Rectangle = obj.getBounds(obj.parent);
    var currentRegX:Number = obj.x - bounds.left;
    var currentRegY:Number = obj.y - bounds.top;

    var xOffset:Number = newX - currentRegX;
    var yOffset:Number = newY - currentRegY;
    //shift the object to its new location--
    //this will put it back in the same position
    //where it started (that is, VISUALLY anyway):
    obj.x += xOffset;
    obj.y += yOffset;

    //shift all the children the same amount,
    //but in the opposite direction
    for(var i:int = 0; i < obj.numChildren; i++) {
        obj.getChildAt(i).x -= xOffset;
        obj.getChildAt(i).y -= yOffset;
    }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文