代码之家  ›  专栏  ›  技术社区  ›  osghaly

比例和转换点

  •  0
  • osghaly  · 技术社区  · 7 年前

    这样做并在末尾添加一些额外的帧后,movieclip从其原始位置移动,变换点从中心移动到导致形状移动的一个角。

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

    1 回复  |  直到 7 年前
        1
  •  0
  •   Atriace    7 年前

    控件可能有问题,但代码应该仍然可以工作。只需在你的 TextField MovieClip .

    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);
    }