7 Replies Latest reply on May 23, 2007 7:31 AM by kglad

# Drawing problems curveTo and lineTo

HI beginner back again!

I have imported a video with 120 cuepoints

The idea is that as the video plays a graph will plot. This works fine (for a change) but i need to make a nice curve and im having problems. I understand that a curveTo works with 4 points but i just want a curve to appear whihc ater will go back to a lineTo method after. has anyone done this?

My code is below whihc works, i have yet to finalise the other cue points but it works i just cant figure out how to put a curve in.

var myCount:Number=0//declare & initialis

createEmptyMovieClip("drawingclip",1)
drawingclip._x=76
drawingclip._y=337
drawingclip.lineStyle(3,0xCC0000)

steel_sample_vid.cuePoint = function() {
myCount+=1//increment variable by 1

if (myCount==1){ //
drawingclip.lineTo(0,-1)
}else if (myCount==2)
{
drawingclip.lineTo(2,-5)
}else if (myCount==3)
{
drawingclip.lineTo(2,-10)
}else if (myCount==4)
{
drawingclip.lineTo(2,-15)
}
else if (myCount==5)
{
drawingclip.lineTo(2,-20)
}
else if (myCount==6)
{
drawingclip.lineTo(2-25)
}
else if (myCount==7)
{
drawingclip.lineTo(2,-30)
}
else if (myCount==8)
{
drawingclip.curveTo(2,-35)
}
else if (myCount==9)
{
drawingclip.lineTo(2,-40)
}
else if (myCount==10)
{
drawingclip.lineTo(2,-45)
}
else if (myCount==11)
{
drawingclip.lineTo(2,-50)
}
else if (myCount==12)
{
drawingclip.lineTo(2,-55)
}
else if (myCount==13)
{
drawingclip.lineTo(2,-60)
}
else if (myCount==14)
{
drawingclip.lineTo(2,-65)
}
else if (myCount==15)
{
drawingclip.lineTo(2,-70)
}
else if (myCount==16)
{
drawingclip.lineTo(2,-75)
}
else if (myCount==17)
{
drawingclip.lineTo(2,-80)
}
else if (myCount==18)
{
drawingclip.lineTo(2,-85)
}
else if (myCount==19)
{
drawingclip.lineTo(2,-90)
}
else if (myCount==20)
{
drawingclip.lineTo(2,-95)
}
else if (myCount==21)
{
drawingclip.lineTo(2,-100)
}
else if (myCount==22)
{
drawingclip.lineTo(2,-105)
}
else if (myCount==23)
{
drawingclip.lineTo(2,-110)
}
else if (myCount==24)
{
drawingclip.lineTo(2,-115)
}
else if (myCount==25)
{
drawingclip.lineTo(2,-120)
}
else if (myCount==26)
{
drawingclip.lineTo(2,-125)
}
else if (myCount==27)
{
drawingclip.lineTo(2,-130)
}
else if (myCount==28)
{
drawingclip.lineTo(2,-135)
}

};

• ###### 1. Re: Drawing problems curveTo and lineTo
you want to curve from where (anchor point) to where (anchor point) and you want the lines from where (controlX,controlY) to each of your anchor points to be tangent to your curve at the anchor points?
• ###### 2. Re: Drawing problems curveTo and lineTo
this is where i really get confused :(

If i want the curve start from 2 (the same as the line) but i want it to end up curving at a nice point to say 145 how would i do this?

Sorry im probably being really dense i have no idea abouot anchor points
• ###### 3. Re: Drawing problems curveTo and lineTo
2 is not a start point and 145 is not an end point. you must designate an x and y coordinate for each point in 2d space.

anchor points are the start and end point. they anchor (or fix) the ends of your curve.

the shape of the curve is determined by the control point. specifically, the shape is determined by the slope of the curve at each anchor point and smoothly making the transition from one anchor to the other.
• ###### 4. Re: Drawing problems curveTo and lineTo
thats a really helpful breakdown i just cant put theory into practice with my graph, i know what i want it to look like curve wise but gettng the correct poiints etc is another matter lol
• ###### 5. Re: Drawing problems curveTo and lineTo
what two points (x and y coordinates are needed for each) do you want to connect and how do you want the curve to look?
• ###### 6. Drawing problems curveTo and lineTo
ONt he movie clip the point a want it to go from is: x: 77.0 y:195.0 i would like it to connect to a point at 112.0 and 185.0. Form here i will continue the code with a lineTo.

The graph will finally look like this: http://www.tech.plymouth.ac.uk/research/lt_area/images/tensile_graph.jpg the curve bit needs to be from just under the 3500 point to just under the 4000 point under 2 on the x axis.

I did a graph just using lineTo but it just looked too blocky and they want a nice small curve instead!

Easy said than done its my first actionscript project!

Thank you for your help :)
• ###### 7. Re: Drawing problems curveTo and lineTo
to start from (77,195) you need to use moveTo(77,195) or lineTo(77,195) or a previous curveTo(xx,yy,77,195) before using your curveTo(xxx,yyy,112,185). i'll use moveTo() in the code below.

next you want to determine your control point (which determines the curves shape). a straight line would have control point right on the line that connects those two points (and if the curve is symmetric between those two points): (94.5,190). that point is in the middle of the line segment connecting your two points

if you want a curve that has a lot of arc use a control point way above (94.5,190) like (94.5,-390) or (94.5,-1000), to curve downwards, for example.

because you want a curve that has a gentle arc, pick a control point just above (94.5,190) like (94.5,180). the closer the y coordinate of the control point is to 190 the more gentle the curve. if the control point 's y is above 190, the curve will arc downwards. if the control control point's y is below 190 the curve will arc up.

try: