Bounce problem!

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

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:

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!

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)

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:

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


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

ahaa… THX alot m8! =)