# Modified kirupa gavity bounce question

**URL:** <https://forum.kirupa.com/t/modified-kirupa-gavity-bounce-question/174572>\
**Category:** Uncategorized\
**Created:** [January 6, 2006, 7:47pm UTC](https://forum.kirupa.com/t/modified-kirupa-gavity-bounce-question/174572 "2006-01-06T19:47:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Goosedroppings](https://avatars.discourse-cdn.com/v4/letter/g/e9c0ed/32.png) [@Goosedroppings](https://forum.kirupa.com/u/Goosedroppings)\
**Post date:** [January 6, 2006, 7:47pm UTC](https://forum.kirupa.com/t/modified-kirupa-gavity-bounce-question/174572/1 "2006-01-06T19:47:14Z")

</div>

hello,

I have 1 ball and 2 buttons.The top button releases the ball and it hits the floor and bounces. The bottom button pulls it back up to the top again.

Currently, it snaps instantly to the top without an ease or bounce. I am trying to have that second button pull it back up and bounce off the ceiling in the same fashion as when it was dropped down but it only seems that the easing and bouncing of the ball happens on the way down.

Could any AS programmers help me out here. I’ve attached the .fla and here is my code:

ball code:

```auto
onClipEvent (enterFrame) {
	if (_root.bar1.Y == 0) {
	
	// We calculate the increase of speed
	// speedx doesn't change
	speedy = speedy+gravity;
	// We move the ball
//	this._x += speedx/5;
	this._y += speedy/5;
	if (this._y>floor) {
		this._y = floor;
		speedy *= -bounce;
		}
	}
	
	else if (_root.bar1.Y == 0) {
	// We calculate the increase of speed
	// speedx doesn't change
	speedy = speedy+gravity;
	// We move the ball
	//	this._x += speedx/5;
	this._y += speedy/5;
	if (this._y>floor) {
		this._y = floor;
		speedy *= -bounce;
		}
	}
}

```

1st button (drops ball)

```auto
on (press) {
	_root.bar1.Y = 0;
	_root.bar1.floor = 586;
	_root.bar1.gravity = 10;
	_root.bar1.bounce = 0.2;
	_root.bar1.speedx = 0;
	_root.bar1.speedy = 0;

}

```

2nd button (pulls ball up)

```auto
on (press) {
	_root.bar1.Y = 0;
	_root.bar1.floor = 14;
	_root.bar1.gravity = 10;
	_root.bar1.bounce = 0.2;
	_root.bar1.speedx = 0;
	_root.bar1.speedy = 0;

}

```

Thank you.
