Hello everyone,
I am creating a routemap that resembles an airline route map. Please take a look at the following:
I have something that resembles this, but my ‘routes’ are just straight lines, dynamically drawn using the drawing API. Example (an *.swf and *.fla are attached to this post containing just this code):
mc = this.createEmptyMovieClip("drawing_mc", 1);
drawing_mc.speed = 1.1; // Any number above 1
drawing_mc.lineToX = drawing_mc.startX = 100;
drawing_mc.lineToY = drawing_mc.startY = 100;
drawing_mc.endX = 350;
drawing_mc.endY = 250;
drawing_mc.onEnterFrame = function(){
// Determine endpoints for lineTo() function below
this.lineToX = this.endX -
(this.endX - this.lineToX)/this.speed;
this.lineToY = this.endY -
(this.endY - this.lineToY)/this.speed;
// Remove previously drawn line
this.clear();
this.lineStyle(2, 0x000000);
this.moveTo(this.startX,this.startY);
this.lineTo(this.lineToX,this.lineToY);
}
My plan is to use curved lines with the curveTo() function. I am trying to do it in a similar fashion as in the example, redrawing the line on every EnterFrame() event. The problem I have is that I need to determine the location of the curve’s control point and end point to create every “sub”-curve until the line has reached its destination.
Is there an easy way of doing this?
I’ve looked into articles about the math behind this (bezier curves, quad curves, tangents and their intersections etc), and I’ve also read through the posts in this forum (a couple of them were really good, however not for my problem…)
Thanks for you time!
Kind regards,
Maurits