A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Simple Drag/Line Follow Script

  1. #1
    Senior Member
    Join Date
    Sep 2000
    Posts
    273
    There were a couple requests about using lineTo in order to draw a following line (like the old 45deg line trick)

    http://perfectweb.org/Simple_Drag_Follow.html
    http://perfectweb.org/Simple_Drag_Follow.fla

    The code is really simple:

    Code:
    ball_mc.onMouseDown = function()
    {
    	if (hitTest(_root._xmouse, _root._ymouse))
    	{
    		startDrag(this, true);
    		dragged = true;
    	}
    }
    ball_mc.onMouseUp = function()
    {
    	if (dragged)
    	{
    		dragged = false;
    		stopDrag();
    	}
    }
    ball_mc.onEnterFrame = function()
    {
    	if (dragged)
    	{
    		_root.clear();
    		_root.lineStyle(5, 0x0000FF, 100);
    		_root.moveTo(275, 200);
    		_root.lineTo(ball_mc._x, ball_mc._y);
    	}
    }
    That's it,

    Spyder

  2. #2
    Developer
    Join Date
    Sep 2001
    Location
    The Bluegrass State Will Flash For Food
    Posts
    3,789
    now how can i make it spring back like it's on a rubber band

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