# Movement

**URL:** https://forum.kirupa.com/t/movement/19765
**Category:** Uncategorized
**Created:** [May 1, 2003, 11:20am UTC](https://forum.kirupa.com/t/movement/19765 "2003-05-01T11:20:16Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![batmitra](https://avatars.discourse-cdn.com/v4/letter/b/85e7bf/32.png) [@batmitra](https://forum.kirupa.com/u/batmitra)
#### Post date: [May 1, 2003, 11:20am UTC](https://forum.kirupa.com/t/movement/19765/1 "2003-05-01T11:20:16Z")

</div>

hi everyone

i need help on this  
i saw this tutorial about movement with actionscript here on kirupa

[http://www.kirupa.com/developer/mx/ASmovement.htm](http://www.kirupa.com/developer/mx/ASmovement.htm)

its great,its working but what i want to know is how can we make the movement stop on determined \_x position,i’ve tryed to put an if statement to stop when it reaches some \_x position ,it worked but it didn’t work smoothly it gets the movieclip to \_x position without the smoothness and i’de like to keep the smooth movement  
can someone help me please?  
thanks

---

<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: [May 1, 2003, 2:49pm UTC](https://forum.kirupa.com/t/movement/19765/2 "2003-05-01T14:49:01Z")

</div>

are you sure you coded right ?  
try this, change the x variable:

```auto

onClipEvent(enterFrame) {
	speed = 1;
	this._x += speed;
        if (this._x >= 100){
             this.stop();
             _root.stop // i'm not sure this is useful
            }
}

```

---

<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: [May 1, 2003, 9:26pm UTC](https://forum.kirupa.com/t/movement/19765/3 "2003-05-01T21:26:34Z")

</div>

hi mlkdesign

thanks for the help

i’ve tried to use it as you said but it doesn’t work ,when the movieclip reachs the \_x=100 it continues to move i don’t know why somehow it seems that it doesn’t “see” the If condition

---

<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: [May 1, 2003, 9:31pm UTC](https://forum.kirupa.com/t/movement/19765/4 "2003-05-01T21:31:02Z")

</div>

MLK - love the footer - gotta click it everytime I see it!!

What I do when I want an AS movement to stop is either tell speed to equal 0. This is what I mean:  
[AS]  
onClipEvent(enterFrame) {  
speed = 1;  
this.\_x += speed;  
if (this.\_x \>= 100){  
speed=0;  
}  
}  
[/AS]  
Can’t move without the pedal down. Hope that helps!!  
(-:

---

<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: [May 1, 2003, 9:52pm UTC](https://forum.kirupa.com/t/movement/19765/5 "2003-05-01T21:52:28Z")

</div>

if you want to stop the MC smoothly, you may want to use easing. an example:

[AS]  
myMC.newx = 400  
myMC.speed = 8  
myMC.onEnterFrame = function () {  
this.\_x = this.\_x-(this.\_x - newx)/this.speed  
}[/AS]  
newx is where you want the MC to stop and speed is how fast you want it to get there. i didn’t check out which tutorial you read so i may be wrong :\*(

hope i helped 🙂

---

<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: [May 1, 2003, 10:01pm UTC](https://forum.kirupa.com/t/movement/19765/6 "2003-05-01T22:01:46Z")

</div>

ok guys  
thanks for all the help but i have figure out myself a solution for this here it is

onClipEvent(EnterFrame){  
count=this.\_x;  
if (count==100){  
this.stop();  
}  
else{  
speed = 1;  
this.\_x += speed;  
count=this.\_x;  
}  
}  
the only thing is to put the condition right which means we have to see first if the movieclip has already reached the position we want and if its true we stop else we continue to move

---

<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: [May 2, 2003, 9:27am UTC](https://forum.kirupa.com/t/movement/19765/7 "2003-05-02T09:27:06Z")

</div>

> \*Originally posted by zylum \*  
> \*\*if you want to stop the MC smoothly, you may want to use easing. an example:

[AS]  
myMC.newx = 400  
myMC.speed = 8  
myMC.onEnterFrame = function () {  
this.\_x = this.\_x-(this.\_x - newx)/this.speed  
}[/AS]  
newx is where you want the MC to stop and speed is how fast you want it to get there. i didn’t check out which tutorial you read so i may be wrong :\*(

hope i helped 🙂 \*\*

this should be…

[AS]myMC.newx = 400  
myMC.speed = 8  
myMC.onEnterFrame = function () {  
this.\_x +=(this.newx-this.\_x )/this.speed  
}[/AS]

cheers =)!

---

<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: [July 12, 2003, 4:17pm UTC](https://forum.kirupa.com/t/movement/19765/8 "2003-07-12T16:17:27Z")

</div>

why to submit pintless var “newx”?

---

<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: [July 12, 2003, 5:06pm UTC](https://forum.kirupa.com/t/movement/19765/9 "2003-07-12T17:06:44Z")

</div>

> \*Originally posted by fluid\_0ne \*  
> \*\*why to submit pintless var “newx”? \*\*

Because if you want to change the location the clip goes to you can just change the value of the newx variable.

---

<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: [July 12, 2003, 9:30pm UTC](https://forum.kirupa.com/t/movement/19765/10 "2003-07-12T21:30:01Z")

</div>

but there’s no need for doing that in this eg.

---

<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: [July 12, 2003, 11:14pm UTC](https://forum.kirupa.com/t/movement/19765/11 "2003-07-12T23:14:52Z")

</div>

You never know…
