规模和转型点

Scale and transformation point

使用变形工具缩放文本或影片剪辑时遇到问题。 我想要做的就是创建补间动画,通过在开始时缩小动画片段然后将其缩放回 100% 来制作缩放效果。

执行此操作并在末尾添加一些额外的帧后,动画片段从其原始位置移动,变形点从中心移动到其中一个角,导致形状移动。

我想知道是否有人可以帮助并告诉我如何解决这个问题..在此先感谢。

控件可能有问题,但代码应该仍然有效。只需将补间应用于 TextFieldMovieClip.

单盒

import flash.display.Sprite;
import fl.transitions.*;
import fl.transitions.easing.*;
import flash.events.Event;

// A demonstration box
var box:Sprite = new Sprite();
box.graphics.beginFill(0xFF);
box.graphics.drawRect(-50, -50, 100, 100);
box.graphics.endFill();
addChild(box)
box.x = box.y = 100;
box.addEventListener("click", animateIn);

function animateIn(e:Event):void {
    // Animate the X then the Y scale.
    var anim:Tween = new Tween(box, "scaleX", Regular.easeOut, 1, 0.5, 1, true);
    new Tween(box, "scaleY", Regular.easeOut, 1, 0.5, 1, true);

    // Listen for the end of the animation, before running the second half.
    anim.addEventListener("motionFinish", animateOut);
}

function animateOut(e:Event):void {
    new Tween(box, "scaleX", Regular.easeOut, 0.5, 1, 1, true);
    new Tween(box, "scaleY", Regular.easeOut, 0.5, 1, 1, true);
}

多个盒子

import flash.display.Sprite;
import fl.transitions.*;
import fl.transitions.easing.*;
import flash.events.Event;

var size:int = 40;
var columns:int = Math.floor(stage.stageWidth / size);
var rows:int = Math.floor(stage.stageHeight / size);

// Create demo boxes
var last:Sprite = null;
for (var c:int = 0; c < columns; c++) {
    for (var r:int = 0; r < rows; r++) {
        var box:Sprite = new Sprite();
        box.graphics.beginFill(0xFF);
        box.graphics.drawRect(-size/2 + 1, -size/2 + 1, size - 2, size - 2);
        box.graphics.endFill();
        addChild(box)

        box.x = c*size + size/2;
        box.y = r*size + size/2;
        box.addEventListener("mouseOver", animateIn);
    }
}

function animateIn(e:Event):void {
    var box:Sprite = e.currentTarget as Sprite;

    // Animate the X then the Y scale.
    var anim:Tween = new Tween(box, "scaleX", Regular.easeOut, 1, 0.5, 0.35, true);
    new Tween(box, "scaleY", Regular.easeOut, 1, 0.5, 0.35, true);

    // Listen for the end of the animation, before running the second half.
    anim.addEventListener("motionFinish", animateOut);
}

function animateOut(e:Event):void {
    new Tween(e.currentTarget.obj, "scaleX", Regular.easeOut, 0.5, 1, 0.35, true);
    new Tween(e.currentTarget.obj, "scaleY", Regular.easeOut, 0.5, 1, 0.35, true);
}