Drawing a line after an arrow that follows a path in a Flash MovieClip

If you've ever tried to draw a line after a moving arrow you know what a pain it can be to make it look good. Fed up with my cheap animation skills using masks and tweens I decided to do this using Actionscript 3. Turned out to be super easy with pretty result.
Basically you have an MC in which another arrow MC moves along a set path. For example going from left to right along some curves. Now I wanted this arrow to draw a tail behind it: In the first mc set the instance name of the arrow to "arrow" and then use this script:

var drawpic:MovieClip = new MovieClip();
addChildAt(drawpic,0);
function startFollow():void {
drawpic.graphics.lineStyle(5, 0xec008c);
drawpic.graphics.moveTo(arrow.x,arrow.y);
addEventListener(Event.ENTER_FRAME, followArrow);
}
function followArrow(e:Event):void {
drawpic.graphics.lineStyle(ls, 0xec008c);
}
function killFollow():void {
removeEventListener(Event.ENTER_FRAME, followArrow);
}

to start drawing, call startFollow function, to end it call killFollow function.

Kommentare

Beliebte Posts aus diesem Blog

Angular is trash

Dropping Clips on Sprite Graphics V2