Gravity along the X-Axis?

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:


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 :stuck_out_tongue: