View Full Version : Draw a curve between two points

02-10-2007, 04:15 PM
hi can u help me with my problem?i want to add a function that draw a curve actually a masked curve between 2 points when i give it the x,y coordinates please help me,or at least tell me where to start from.I am biulding a dynamic map and after choosing the destination from the combobox i would like to add a curve between the 2 places,it is imposible to do it manually coz i need more than 900 animation!! please help

02-10-2007, 04:40 PM
From Flash help:

this.createEmptyMovieClip("circle_mc", 10);
circle_mc._x = 100;
circle_mc._y = 100;
drawCircle(circle_mc, 100, 0x99FF00, 100);
function drawCircle(target_mc:MovieClip, radius:Number, fillColor:Number, fillAlpha:Number):Void {
var x:Number = radius;
var y:Number = radius;
with (target_mc) {
beginFill(fillColor, fillAlpha);
moveTo(x+radius, y);
curveTo(radius+x, Math.tan(Math.PI/8)*radius+y, Math.sin(Math.PI/4)*radius+x, Math.sin(Math.PI/4)*radius+y);
curveTo(Math.tan(Math.PI/8)*radius+x, radius+y, x, radius+y);
curveTo(-Math.tan(Math.PI/8)*radius+x, radius+y, -Math.sin(Math.PI/4)*radius+x, Math.sin(Math.PI/4)*radius+y);
curveTo(-radius+x, Math.tan(Math.PI/8)*radius+y, -radius+x, y);
curveTo(-radius+x, -Math.tan(Math.PI/8)*radius+y, -Math.sin(Math.PI/4)*radius+x, -Math.sin(Math.PI/4)*radius+y);
curveTo(-Math.tan(Math.PI/8)*radius+x, -radius+y, x, -radius+y);
curveTo(Math.tan(Math.PI/8)*radius+x, -radius+y, Math.sin(Math.PI/4)*radius+x, -Math.sin(Math.PI/4)*radius+y);
curveTo(radius+x, -Math.tan(Math.PI/8)*radius+y, radius+x, y);
// I have added the following

02-10-2007, 04:55 PM
thanx 4 answer but will u further explain what this code will work in? and where do i add it

02-10-2007, 05:20 PM
thanx for answering my previois thread but maybe u miss understood me i would like to draw a curve between 2 known points not a circle how can i do that u can visit : http://www.ryanair.com/site/EN/dests.php?flash=chk so that u might get what i mean

02-10-2007, 06:07 PM
This script creates an empty movie clip named "circle_mc" in depth 10, locates it in (100,100) coordinates, then in this mc it creates a circle with dimensions 100x100px.

In the last lines I assumed the instance name of the mc you want to be masked by this circle is "my_mc" and masked that with the "circle_mc".

This script is located in the frame (actions) where you want to create the masking process.

What, in this code, actually defines the radius of the circle is:
drawCircle(circle_mc, 100, 0x99FF00, 100);

and what defines the _x/_y pos is:
circle_mc._x = 100;
circle_mc._y = 100;

If you don't want an absolute circle but an ellipse, you need to modify the drawCircle function code (but I'm not familiar with that, so I can't help).

02-10-2007, 06:34 PM
Take a look at Flash help with curveTo (MovieClip.curveTo method)

And please, use "private message" function when you want to communicate one-to-one rather than opening new threads..

02-10-2007, 08:56 PM
Hey dude

use the drawing API in Flash and for the curves I suggest u tage a look at the FUSE kit at www.mosessupposes.com witch will be able to do everything like ryanAir did.

Check out www.gotoandlearn.com where Lee Brimelow shows a couple of FUSE video tutorials :)

Hope this helps u out :)