A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: Drawing a curved line

  1. #1
    Senior Member
    Join Date
    Dec 2001
    Posts
    169

    [Resolved] Drawing a curved line

    Hi guys,

    I need to draw a curve line from point A (fixed) to the mouse loc.
    Anyone knows how to script that?

    Basically it's for a "fishing" game where my point A is the start of my fishing line, and the mouse will act as the bait. The user will just guide the bait around the screen to catch items. The line will keep redrawing.

    Cheers,
    Thanks in advance and happy new year!
    Last edited by s7N; 01-22-2007 at 12:36 AM. Reason: [Resolved]
    -s7N
    ___________________________________
    time you enjoy wasting, isnt wasted

  2. #2
    Student
    Join Date
    Apr 2001
    Location
    -
    Posts
    4,756
    look in the flash help for the drawing API, there you should find as well the curveTo(); command. Combine that one with lineTo(); and you should have a curve
    Very easy to understand in the help

  3. #3
    Senior Member
    Join Date
    Dec 2001
    Posts
    169
    Thanks for the reply.
    Hmm.. I managed to draw a straight line from the point till mouse with the lineTo.. But don't really get how the curveTo works..
    -s7N
    ___________________________________
    time you enjoy wasting, isnt wasted

  4. #4
    Student
    Join Date
    Apr 2001
    Location
    -
    Posts
    4,756
    some little insight:
    http://www.toxiclab.org/tutorial.asp?ID=101

    the flash curveTo method uses the quadratic bezir method:

    read all about you need to know here:
    http://livedocs.macromedia.com/flash...=00002450.html

  5. #5
    Senior Member
    Join Date
    Dec 2001
    Posts
    169
    Thanks thanks. Managed to get it to work, by setting a function to keep drawing a curve line from point to mouse.
    Thanks.
    -s7N
    ___________________________________
    time you enjoy wasting, isnt wasted

  6. #6
    Student
    Join Date
    Apr 2001
    Location
    -
    Posts
    4,756
    and you understand how you influence the curve now?
    it´s just like you do in flash with the line and move manipulator, - the line becomes a curve and points (1 edge, not 2 like in freehand, illustrator,...) to where you drag the mouse- same goes the curve to command.

    you could add some fx by drawing multiple lines over each other but each one a little bit thinner ( lineStyle(x,...); ) that way you´ll get outlines or even gradients within the stroke if you use enough layered lines

  7. #7
    Senior Member
    Join Date
    Dec 2001
    Posts
    169
    Yea, the two points will act as a anchor point to curve the line. By tweaking the two points and also adding a little bit of random(10), i managed to make it look pretty much like a fishing line in water.
    Cheers.
    -s7N
    ___________________________________
    time you enjoy wasting, isnt wasted

  8. #8
    purple lizard
    Join Date
    Jan 2007
    Location
    somewhere in the world
    Posts
    85
    Pls dont say i bumped this... there is an API drawing tool that produces the code for you here, and an API animator that does the same here

  9. #9
    Senior Member
    Join Date
    Dec 2001
    Posts
    169
    Wow, gecko, nice links, very useful applications. Bet it'll come in handy someday.
    -s7N
    ___________________________________
    time you enjoy wasting, isnt wasted

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center