规模和转型点

时间:2017-08-08 13:13:50

标签: actionscript-3 adobe animate-cc

使用转换工具缩放Text或Movieclip时遇到问题。 我想要做的就是创建补间动画以通过在开始时缩小动画片段然后将其缩放回100%来制作缩放效果。

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

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

1 个答案:

答案 0 :(得分:0)

控件可能会很糟糕,但代码仍然有用。只需将补间应用到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);
}