# Bounce problem!

**URL:** <https://forum.kirupa.com/t/bounce-problem/6690>\
**Category:** Uncategorized\
**Created:** [October 14, 2002, 11:37am UTC](https://forum.kirupa.com/t/bounce-problem/6690 "2002-10-14T11:37:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jerry](https://avatars.discourse-cdn.com/v4/letter/j/5daacb/32.png) [@jerry](https://forum.kirupa.com/u/jerry)\
**Post date:** [October 14, 2002, 11:37am UTC](https://forum.kirupa.com/t/bounce-problem/6690/1 "2002-10-14T11:37:54Z")

</div>

hey guys!

this is kinda hard to explain, but I’ll try!  
I’m making a MC follow the mouse in a bouncy way, take alook at the following example:

[example](http://www.deuxfemmes.dk/test/bounce.htm)

Now this works fine, but what I want it to do is, to stay inside the boxes, so it only bounces when I move the mouse over a “new empty” box! …how can this be done??

Here is my code:

```auto
onClipEvent(load){
velY = 0
acc = 4
dec = 1.2
}
onClipEvent(enterFrame){
currY = this._y
targetY = _root._ymouse
velY = (velY + (targetY - currY) * 1 / acc) / dec
this._y += velY
}

```

I’ve attached the .fla to!

---

<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 14, 2002, 12:36pm UTC](https://forum.kirupa.com/t/bounce-problem/6690/2 "2002-10-14T12:36:20Z")

</div>

For some reason I couldn’t open the .fla but I think I can give ya some ideas.  
Give the buttons some actions that when you rollover one it assigns a new value for currY  
For example  
the “thing”'s Ypos = 10  
You rollOver the second box which has a Ypos value of 40;  
on(rollOver) {  
\_root.currY = 40;  
}  
and that’s it!  
OH I almost forgot!  
add “\_root.” in front of each variable  
It’s good to store all the actions in \_root (the main timeline) (otherwize it won’t work too)

---

<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 14, 2002, 1:04pm UTC](https://forum.kirupa.com/t/bounce-problem/6690/3 "2002-10-14T13:04:42Z")

</div>

THX for your help dude! …but I still can’t get it to work the way it should, is it possible for you to add a tiny .fla so I could see exactly what you mean…? :nerd:

---

<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 14, 2002, 3:13pm UTC](https://forum.kirupa.com/t/bounce-problem/6690/4 "2002-10-14T15:13:51Z")

</div>

omg! 00ps sorry! I meant targetY not currY !

* * *

You had to change currY… =) 🙂 =)  
so anyways here’s the .fla

---

<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 14, 2002, 8:47pm UTC](https://forum.kirupa.com/t/bounce-problem/6690/5 "2002-10-14T20:47:55Z")

</div>

ahaa… THX alot m8! =)
