7 Replies Latest reply on Apr 4, 2008 4:58 PM by kglad

    draw using lineTo

    ActionB
      I have a basic line drawing animation - a ball moves along a motion guide path and leaves a line. What's a good way to do this with ActionScript 2.0?

      So far, I'm working with this AS:
      _root.onEnterFrame = function(){
      moveTo(ball_mc._x,ball_mc._y);
      lineTo(ball_mc._x, ball_mc._y);
      lineStyle(2,0x000000,100);
      }

      This would look like an etch-a-sketch, or Tron game, but would be guided by a motion path in a guide layer.
        • 1. Re: draw using lineTo
          kglad Adobe Community Professional & MVP
          the moveTo() should be execute once before your onEnterFrame loop executes.
          • 2. Re: draw using lineTo
            ActionB Level 1
            Thanks kglad! I think I'm getting the logic looking at a number of examples.
            Would I head in this direction?

            onClipEvent (load) {
            moveTo(ball_mc._x,ball_mc._y);
            _root.onEnterFrame = function(){
            lineTo(ball_mc._x, ball_mc._y);
            lineStyle(3, 0xee3355, 100);
            }

            Or this direction:

            onClipEvent (load) {
            /* x & y co-ordinate for the movieclip code.*/
            x1 = _parent.ball_mc._x;
            y1 = _parent.ball_mc._y;
            moveTo(x1,y1);
            lineStyle(3, 0xee3355, 100);
            }
            onClipEvent (enterFrame) {
            lineTo(_parent.code._x, _parent.code._y);
            }
            • 3. Re: draw using lineTo
              kglad Adobe Community Professional & MVP
              it can get messy if you attach the line api to the object you want to use as the lineTo target.

              attached to the timeline that contains ball_mc, try:



              • 4. Re: draw using lineTo
                ActionB Level 1
                Thanks again. The cleaner the better. I tried that in my actionscript layer and in the layer called "ball" with the ball in it. The code checks out but no result.
                Does onEnterFrame require the mouse enter the frame? Would onLoad work better in the vein?
                Does the holder need to be defined (does it need to fit the screen?)

                The fla is here if that makes it easier.
                Once again, your help is much appreciated.

                • 5. Re: draw using lineTo
                  kglad Adobe Community Professional & MVP
                  you don't have a movieclip with instance name ball_mc. in fact, you're using a graphic which can't be assigned an instance name.

                  to remedy convert your graphic to a movieclip and give it the instance name of ball_mc (in the properties panel).
                  • 6. Re: draw using lineTo
                    ActionB Level 1
                    Aye yi yi... One more reason to see the eye doctor! If you're ever in Baltimore, you got yourself a cold one on me kglad.
                    • 7. Re: draw using lineTo
                      kglad Adobe Community Professional & MVP
                      thanks!