# Cord phone drag effect

**URL:** <https://forum.kirupa.com/t/cord-phone-drag-effect/284478>\
**Category:** Uncategorized\
**Created:** [March 19, 2009, 2:53pm UTC](https://forum.kirupa.com/t/cord-phone-drag-effect/284478 "2009-03-19T14:53:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![amaze](https://avatars.discourse-cdn.com/v4/letter/a/13edae/32.png) [@amaze](https://forum.kirupa.com/u/amaze)\
**Post date:** [March 19, 2009, 2:53pm UTC](https://forum.kirupa.com/t/cord-phone-drag-effect/284478/1 "2009-03-19T14:53:24Z")

</div>

Hi all!

link: [http://www.media-ware.net/cord/test04.html](http://www.media-ware.net/cord/test04.html)

I’ve created this effect when you drag 'n drop the phone, but for some reason that I can’t get right now when you drag it to the left or to the right it takes a lot of time to find its cord.

Can someone please help me out?

I tried using the cords bottom to send the phone’s \_x & \_y but I didn’t manage it.

Thanks all!

here’s the code used on phone movieclip:

ycord\_mc is the cord movieclip and ycordinside\_mc is the movieclip inside it.

```auto
onClipEvent (load) {
	tx = _x;
	ty = _y;
	tr = 0;
	ch = _parent.ycord_mc.ycordinside_mc._height;
	k = .3;
	damp = .86;
    vx = 0;
    vy = 0;
    vr = 0;
    vc = 0;
} 

onClipEvent (enterFrame) {
	if(!drag){
		ax = (tx - _x) * k;
		ay = (ty - _y)* k;
		ar = (tr - _parent.ycord_mc._rotation) * k;
		ac = (ch - _parent.ycord_mc.ycordinside_mc._height) * k;
		vx += ax;
		vy += ay;
		vr += ar;
		vc += ac;
		vx *= damp;
		vy *= damp;
		vr *= damp;
		vc *= damp;
		_x += vx;
		_y += vy;
		_parent.ycord_mc._rotation += vr;
		_parent.ycord_mc.ycordinside_mc._height += vc;
		//_parent.ycord_mc.ycordinside_mc._height = Math.sqrt(Math.pow((_parent.yphone_mc._y - _parent.ycord_mc._y), 2) + Math.pow((_parent.yphone_mc._x - _parent.ycord_mc._x), 2));
	} else {
		adjside =_parent.yphone_mc._x - _parent.ycord_mc._x;
		oppside = -1*(_parent.yphone_mc._y - _parent.ycord_mc._y);
		
		angle = Math.atan2(oppside, adjside); // in radians
		angle = Math.round(angle/Math.PI*180); // convert to degrees
		_parent.ycord_mc._rotation = -1*(angle) - 90;
		_parent.ycord_mc.ycordinside_mc._height = Math.sqrt(Math.pow((_parent.yphone_mc._y - _parent.ycord_mc._y), 2) + Math.pow((_parent.yphone_mc._x - _parent.ycord_mc._x), 2));
	}
}

on (press) {
	startDrag("");
	drag = true;
}
on (release, releaseOutside) {
	stopDrag();
	drag = false;
}

```
