# Gravity along the X-Axis?

**URL:** <https://forum.kirupa.com/t/gravity-along-the-x-axis/151287>\
**Category:** flash\
**Created:** [June 14, 2005, 4:56pm UTC](https://forum.kirupa.com/t/gravity-along-the-x-axis/151287 "2005-06-14T16:56:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vexir](https://avatars.discourse-cdn.com/v4/letter/v/a183cd/32.png) [@Vexir](https://forum.kirupa.com/u/Vexir)\
**Post date:** [June 14, 2005, 4:56pm UTC](https://forum.kirupa.com/t/gravity-along-the-x-axis/151287/1 "2005-06-14T16:56:47Z")

</div>

Hey, referring to Pom’s tutorial on gravity (up and down), I was wondering how to alter the code to make it so that the object moved and bounced along the x-axis. I tried this:

```auto

onClipEvent (load) {

	gravity = 2 ;

	// We get the time when the ball is released for the
	// first time. Be careful with the division by 100
	time = getTimer () ;
	time /= 100 ;
	
	floor = 51 ;
	
	bounce = 0.22 ;
	
	// We set the speed of the ball when it is released.
	speedx = 0 ;
	speedystart = 0 ;
}

onClipEvent (enterFrame) {

	// We get the current time (still /100)
	timenow = getTimer () ;
	timenow /= 100 ;
	speedy = gravity * (timenow - time) + speedystart ;
	
	//We move the ball
	this._x += speedx/5 ;
	this._y += speedy/5 ;
	
	if (this._x > floor) {
		this._x = floor ;
		speedy *= -bounce ;
		time = getTimer () ;
		time /= 100 ;
		// reset the timer
		speedystart = speedy ;
		// reset the starting speed
	}
}

```

But it didn’t really work properly (the code executed but it didn’t do the thing right.)

Thanks,

Your fav. AS newbie 😛
