# Constrain x movement

**URL:** https://forum.kirupa.com/t/constrain-x-movement/59803
**Category:** Uncategorized
**Created:** [August 4, 2004, 1:00am UTC](https://forum.kirupa.com/t/constrain-x-movement/59803 "2004-08-04T01:00:07Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![jmzx](https://avatars.discourse-cdn.com/v4/letter/j/91b2a8/32.png) [@jmzx](https://forum.kirupa.com/u/jmzx)
#### Post date: [August 4, 2004, 1:00am UTC](https://forum.kirupa.com/t/constrain-x-movement/59803/1 "2004-08-04T01:00:07Z")

</div>

first my actionscript still sux… so any help pls 😉

i have this script attatched to the object i want to move with mouse…  
only i want to constrain the x movement to another object in the same timeline… i’ve been able to find lots of stuff related to dragging, but how to apply constraints without drag function?

onClipEvent (enterFrame) {  
this.\_x = \_root.xvalue=\_root.\_xmouse;  
}

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 4, 2004, 1:18pm UTC](https://forum.kirupa.com/t/constrain-x-movement/59803/2 "2004-08-04T13:18:27Z")

</div>

```php

onClipEvent (enterFrame) {
	if (this._x > max._x) {
		this._x = max._x;
	}
}

```

I think

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 4, 2004, 5:44pm UTC](https://forum.kirupa.com/t/constrain-x-movement/59803/3 "2004-08-04T17:44:32Z")

</div>

yep cheers Vinc3 your a \* … james

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 5, 2004, 3:57am UTC](https://forum.kirupa.com/t/constrain-x-movement/59803/4 "2004-08-05T03:57:59Z")

</div>

hmmm still no joy, what something like this?

onClipEvent (enterFrame) {  
this.\_x = \_root.xvalue=\_root.\_xmouse;  
}  
onClipEvent (enterFrame) {  
if (this.\_x=\_root.site.box) {  
this.\_x = max.\_x;  
}  
}

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 5, 2004, 6:12am UTC](https://forum.kirupa.com/t/constrain-x-movement/59803/5 "2004-08-05T06:12:19Z")

</div>

> [@jmzx](#):
>
> yep cheers Vinc3 your a \* … james

I’m a what?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 5, 2004, 5:01pm UTC](https://forum.kirupa.com/t/constrain-x-movement/59803/6 "2004-08-05T17:01:59Z")

</div>

a star… -\> \* you know… little pointy thing (for helping).

sorry for confuzion, brain melting… aghhhhh! still need your help

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 6, 2004, 8:56am UTC](https://forum.kirupa.com/t/constrain-x-movement/59803/7 "2004-08-06T08:56:06Z")

</div>

what’s wrong this time?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 6, 2004, 9:50am UTC](https://forum.kirupa.com/t/constrain-x-movement/59803/8 "2004-08-06T09:50:25Z")

</div>

> [@jmzx](#):
>
> hmmm still no joy, what something like this?
> 
> onClipEvent (enterFrame) {  
> this.\_x = \_root.xvalue=\_root.\_xmouse;  
> }  
> onClipEvent (enterFrame) {  
> if (this.\_x=\_root.site.box) {  
> this.\_x = max.\_x;  
> }  
> }

You can’t declare multiple onClipEvent (enterFrame) event handlers without overwriting them.

I’m not sure I understand what you’re trying to do. If you want to be able to drag your clip up to the position of another clip, you could do it like that:

```auto
onClipEvent (enterFrame) {
	this._y = _root._ymouse ;
	this._x = Math.min (_root._xmouse, _root.site.box._x) ;
}

```

Is that what you’re trying to do?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 6, 2004, 10:29am UTC](https://forum.kirupa.com/t/constrain-x-movement/59803/9 "2004-08-06T10:29:31Z")

</div>

> [@Ilyas le G(r)eek](#):
>
> You can’t declare multiple onClipEvent (enterFrame) event handlers without overwriting them.
> 
> I’m not sure I understand what you’re trying to do. If you want to be able to drag your clip up to the position of another clip, you could do it like that:
> 
> ```auto
> onClipEvent (enterFrame) {
> this._y = _root._ymouse ;
> this._x = Math.min (_root._xmouse, _root.site.box._x) ;
> }
> 
> ```
> 
> Is that what you’re trying to do?

I picked that up too, but I didn’t know it was a major prob…hehe

PS: Hello, Ilyas le G(r)eek 😛

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 6, 2004, 6:17pm UTC](https://forum.kirupa.com/t/constrain-x-movement/59803/10 "2004-08-06T18:17:00Z")

</div>



---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 6, 2004, 6:25pm UTC](https://forum.kirupa.com/t/constrain-x-movement/59803/11 "2004-08-06T18:25:58Z")

</div>

‘’’ thanx both for explaining that you can’t declare multiple event handlers. ‘’’

… perhaps if i explain my objectives better than before…

i want to move one clip by the x (\<-\>) movement of the mouse.  
and constrain the movement of that clip, to the x (\<-\>width) of another clip.

‘’’ silly of me not to make that clear in the first place,  
tired, not even sure what i’m doing myself, but thanx guys ‘’’ James

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [August 6, 2004, 11:13pm UTC](https://forum.kirupa.com/t/constrain-x-movement/59803/12 "2004-08-06T23:13:42Z")

</div>

Key Movement: [http://www.kirupa.com/developer/mx/movement\_keys.htm](http://www.kirupa.com/developer/mx/movement_keys.htm)

to constrain, is like what i said before (-:

or what Ilyas le G®eek said
