5 Replies Latest reply on Mar 21, 2007 12:48 PM by kglad

    Cable simulation

      Hey all. I'm trying to get a cable-looking line to work. I found kglad's post from last year, but it doesn't seem to be a general solution (using Flash 8; are there incompatibilities?) . In particular, when catenaryApprox is passed xmouse and ymouse for the first pair and a constant for the second pair, the parabola becomes horizontal when the mouse is in the proximity of a line abs(k*(t-a)-b), where k appears to be an exponential function of the cable 'length' and a and b are the constant pair coordinates for the second point.

      Above this line, all behaves as it should. Below this line, the parabola inverts; in the proximity of this line, the parabola goes horizontal. I suspect that this is a result of the approximations used, but I've no proof of this. Can anyone duplicate these results? I've had trouble in the past with corrupted Flash Player installations.

      Out of monkey curiosity, kglad, where did those equations come from? I see that you're finding the intersection point, but where do the derivatives come from?

      I'm trying to expand the equations for crtlX and crtlY, so I can figure out why it's exploding; I'm also trying to find a quick way to fix the y-coordinate inversion. kglad's code is attached. I've found several good references at

      Any help is appreciated. Many thanks.
        • 1. Re: Cable simulation
          kglad Adobe Community Professional & MVP
          the assumption in the first line of catenaryApprrox() is that y1<=y2. if you're dragging your mouse around, you can expect problems when y1>y2.

          to remedy:

          • 2. Re: Cable simulation
            Bob_Robertson Level 1
            While I feel stupid for not having noticed that, it didn't help. Symptoms remain the same; further, I forgot to add that when the constant point is (a,b) and the mouse is hovered over the base point, the result is a diagonal line from (a,b) to (a/2, b/2).
            Many thanks for your time, kglad. I'm sorry to keep bringing this up.
            • 3. Re: Cable simulation
              kglad Adobe Community Professional & MVP
              well, you can't expect a catenary to exist when x1=x2. here's code to prevent that attempt:

              • 4. Cable simulation
                Bob_Robertson Level 1
                Okay, so I got to playing around with this and I came up with the following solution. It makes no pretensions whatsoever to mathematical correctness, but it looks about right and even looks like it "runs out of cord". Many thanks for your time, kglad. Just attach the attached code to an empty movie clip; it generates a cable-like curve from that clip's location to the mouse pointer's location.

                EDIT: Looking at it, I noticed that it doesn't do much to play nice with the layering system. That might be a problem; it might not. I've not tested it.
                • 5. Re: Cable simulation
                  kglad Adobe Community Professional & MVP
                  you're welcome.