# Flash/actionscript help

**URL:** <https://forum.kirupa.com/t/flash-actionscript-help/263005>\
**Category:** Uncategorized\
**Created:** [June 11, 2008, 8:27pm UTC](https://forum.kirupa.com/t/flash-actionscript-help/263005 "2008-06-11T20:27:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![easymazuma](https://avatars.discourse-cdn.com/v4/letter/e/edb3f5/32.png) [@easymazuma](https://forum.kirupa.com/u/easymazuma)\
**Post date:** [June 11, 2008, 8:27pm UTC](https://forum.kirupa.com/t/flash-actionscript-help/263005/1 "2008-06-11T20:27:36Z")

</div>

I have a line connecting two objects. But one of the objects is draggable. How can I keep it so that the line stays connected to the draggable object, and expands or gets shorter as the dragged object is dragged around the screen? Here is a picture:

[http://img381.imageshack.us/img381/7158/ideaxs5.gif](http://img381.imageshack.us/img381/7158/ideaxs5.gif)

The picture is draggable and I need the line to stay connected at all times and adject. Thanks for the help.

---

<div class="post-metadata">

**Author:** ![snickelfritz](https://avatars.discourse-cdn.com/v4/letter/s/7ea924/32.png) [@snickelfritz](https://forum.kirupa.com/u/snickelfritz)\
**Post date:** [June 11, 2008, 11:33pm UTC](https://forum.kirupa.com/t/flash-actionscript-help/263005/2 "2008-06-11T23:33:51Z")

</div>

This sort of works.  
Sorry, I don’t have time to fiddle with it any longer.  
GL  
Example:[[COLOR=“Blue”][U]http://www.byrographics.com/AS3/dragBox/dragBox.html[/U][/COLOR]](http://www.byrographics.com/AS3/dragBox/dragBox.html)

```auto
/*
There's a movieclip on the stage instance name: "box"
This is the little picture you drag around the stage.
*/
box.addEventListener(MouseEvent.MOUSE_DOWN, boxDown, false, 0, true);
stage.addEventListener(MouseEvent.MOUSE_UP, boxUp, false, 0, true);

function boxDown(e:MouseEvent):void {
	stage.addEventListener(MouseEvent.MOUSE_MOVE, boxMove);
	Yoffset = mouseY - box.y;
	Xoffset = mouseX -box.x;
}

function boxUp(e:MouseEvent):void {
	stage.removeEventListener(MouseEvent.MOUSE_MOVE, boxMove);
}

var Yoffset:Number;
var Xoffset:Number;
var canvas:Shape = new Shape();
addChild(canvas);
var g:Graphics = canvas.graphics;

function boxMove(e:MouseEvent):void {
	
	box.y = mouseY - Yoffset;
	box.x = mouseX - Xoffset;
	Yoffset = mouseY - box.y;
	Xoffset = mouseX - box.x;

	g.clear();
	g.lineStyle(1, 0x000000);
	g.moveTo(200, 200);
	g.lineTo(mouseX, mouseY);

	addChild(box);
	e.updateAfterEvent();
}

```
