# Bouncing box

**URL:** <https://forum.kirupa.com/t/bouncing-box/7185>\
**Category:** Uncategorized\
**Created:** [October 25, 2002, 3:45am UTC](https://forum.kirupa.com/t/bouncing-box/7185 "2002-10-25T03:45:31Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![buddylee](https://avatars.discourse-cdn.com/v4/letter/b/e5b9ba/32.png) [@buddylee](https://forum.kirupa.com/u/buddylee)\
**Post date:** [October 25, 2002, 3:45am UTC](https://forum.kirupa.com/t/bouncing-box/7185/1 "2002-10-25T03:45:31Z")

</div>

I want to make a box come from off screen then bounce back and forth and then come settled down in the middle of the screen. It can be random bouning intervels or a set amount, it really does not matter. Does anyone think they can point me in the right direction?  
Thank ya

---

<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:** [October 25, 2002, 4:39am UTC](https://forum.kirupa.com/t/bouncing-box/7185/2 "2002-10-25T04:39:50Z")

</div>

Sure… make the box a movie clip, place it where you want it to start from, then add the following code to the outside of it.

onClipEvent(enterFrame){  
xVelocity=this.\_x-200; //assuming that your movie is 400 across  
xVelocity\*=.94;  
this.\_x+=xVelocity;  
}

At least I think that will work. If not, just tell me and I’ll fix it. It may be that the numbers are reversed… I’m doing it from memory. 🙂

---

<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:** [October 25, 2002, 3:03pm UTC](https://forum.kirupa.com/t/bouncing-box/7185/3 "2002-10-25T15:03:14Z")

</div>

it didnt bounce back and forth, it just went straight off the stage to the left really fast. I dunno

---

<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:** [October 25, 2002, 3:16pm UTC](https://forum.kirupa.com/t/bouncing-box/7185/4 "2002-10-25T15:16:39Z")

</div>

lol. I’ll work it out. I’m home now. Give me a minute or two.

---

<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:** [October 25, 2002, 3:38pm UTC](https://forum.kirupa.com/t/bouncing-box/7185/5 "2002-10-25T15:38:16Z")

</div>

you can try this. I find it to be a little choppy, but it works

onClipEvent(enterFrame){  
diff=200-this.\_x;  
velocity+=diff;  
velocity\*=.94;  
\_x+=velocity;  
}

---

<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:** [October 25, 2002, 3:40pm UTC](https://forum.kirupa.com/t/bouncing-box/7185/6 "2002-10-25T15:40:08Z")

</div>

sweet man, thanks a bunch bro

---

<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:** [October 25, 2002, 5:44pm UTC](https://forum.kirupa.com/t/bouncing-box/7185/7 "2002-10-25T17:44:22Z")

</div>

You can just adjust it like as you wish:

```auto
onClipEvent(enterFrame){
  diff=200-this._x;
  velocity+=diff*.2;
  velocity*=.94;
  _x+=velocity;
}

```

And there’s a Springs tutorial too.

pom 🙂
