# Help animating a stroke AS 2.0

**URL:** <https://forum.kirupa.com/t/help-animating-a-stroke-as-2-0/263712>\
**Category:** flash\
**Created:** [June 18, 2008, 3:26pm UTC](https://forum.kirupa.com/t/help-animating-a-stroke-as-2-0/263712 "2008-06-18T15:26:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![stv](https://avatars.discourse-cdn.com/v4/letter/s/ce73a5/32.png) [@stv](https://forum.kirupa.com/u/stv)\
**Post date:** [June 18, 2008, 3:26pm UTC](https://forum.kirupa.com/t/help-animating-a-stroke-as-2-0/263712/1 "2008-06-18T15:26:19Z")

</div>

My goal is to get a single stroke to animate randomly every time I open the animation. My code seems to be creating a new strokes during the animation causing them to stack on top of each other. This animation would work if only the previous stroke did not multiply.

```auto
import mx.transitions.Tween;
import mx.transitions.easing.*;

var randomDistance:Number = Math.random()*250
var randomStageDistance:Number = Math.random()*Stage.width

var anchorAAnimation:Tween = new Tween(anchorA, "_y", Regular.easeInOut, 100, randomDistance, 3, true);
var anchorBAnimation:Tween = new Tween(anchorB, "_y", Regular.easeInOut, 200, randomDistance, 3, true);

anchorAAnimation.onMotionFinished = anchorBAnimation.onMotionFinished = function(){;
this.yoyo();
};

this.createEmptyMovieClip("activeline",this.getNextHighestDepth());
activeline.lineStyle(3,0x000000,100,true,"none","none","round",1);

moveLineNow=function(){
    activeline.moveTo(anchorA._x,anchorA._y);
    activeline.curveTo(randomStageDistance,randomDistance,anchorB._x,anchorB._y);
}

setInterval(moveLineNow, 50, img1_mc);

```

---

<div class="post-metadata">

**Author:** ![kyot](https://avatars.discourse-cdn.com/v4/letter/k/b4bc9f/32.png) [@kyot](https://forum.kirupa.com/u/kyot)\
**Post date:** [June 18, 2008, 6:07pm UTC](https://forum.kirupa.com/t/help-animating-a-stroke-as-2-0/263712/2 "2008-06-18T18:07:50Z")

</div>

Yeah Ive been having the same problem. Whenever I animate a stroke with curveTo or lineTo using tween classes, I get a weird effect where the line just looks like there are various versions of itself. I don’t get what makes it do that. Anyone have any ideas?
