0

如何使用Action Script在Flash中绘制对角线效果?我使用补间动画制作动画,然后尝试从该补间动画生成动作脚本,但动画从屏幕中间开始,然后绘制它。它应该从左角开始,因为它是在常规动画中制作的。这是它生成的动作脚本:

import fl.motion.Animator;
var laser_xml:XML = <Motion duration="75" xmlns="fl.motion.*" xmlns:geom="flash.geom.*" xmlns:filters="flash.filters.*">
    <source>
        <Source frameRate="25" x="13.6" y="13.25" scaleX="1" scaleY="1" rotation="0" elementType="drawing object">
            <dimensions>
                <geom:Rectangle left="10" top="10" width="7.25" height="6.5"/>
            </dimensions>
            <transformationPoint>
                <geom:Point x="-1.3793103448275863" y="-1.5384615384615385"/>
            </transformationPoint>
        </Source>
    </source>

    <Keyframe index="0"/>

    <Keyframe index="74" x="188.70000000000002" y="189.05"/>
</Motion>;

var laser_animator:Animator = new Animator(laser_xml, laser);
laser_animator.play();
4

1 回答 1

1

不确定您是在询问如何修改生成的代码,还是仅使用 AS3 进行。如果是后者,这会给你想要的效果。请注意,虽然使用 Tweening 库(例如 TweenLite 或 GTween)会更干净:

var s:Shape = new Shape();
addChild(s); 

var startPoint:Point = new Point();
var endPoint:Point = new Point();
var prog:Number = 0;
var frames:int = 200;

animateLine(100,100,50,50);

function animateLine(startX:Number, startY:Number, endX:Number, endY:Number, time:Number = 120):void {
    startPoint.x = startX;
    startPoint.y = startY;
    endPoint.x = endX;
    endPoint.y = endY;

    frames = time;
    prog = 0;
    this.addEventListener(Event.ENTER_FRAME, tick);
}

function drawLineTick(progress:Number):void{
    s.graphics.clear();
    s.graphics.lineStyle(3,0xFF0000);
    s.graphics.moveTo(startPoint.x,startPoint.y);
    s.graphics.lineTo(startPoint.x + ((endPoint.x - startPoint.x) * progress), startPoint.y + ((endPoint.y - startPoint.y) * progress));
}

function tick(e:Event):void {
    trace("tick",prog);
    if(prog >= frames){
        this.removeEventListener(Event.ENTER_FRAME, tick);
    }

    drawLineTick(prog / frames);
    prog += 1;
} 
于 2012-06-28T23:19:57.130 回答