# Help with acceleration script

**URL:** <https://forum.kirupa.com/t/help-with-acceleration-script/49943>\
**Category:** flash\
**Created:** [April 28, 2004, 3:07am UTC](https://forum.kirupa.com/t/help-with-acceleration-script/49943 "2004-04-28T03:07:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ColbyW](https://avatars.discourse-cdn.com/v4/letter/c/a183cd/32.png) [@ColbyW](https://forum.kirupa.com/u/ColbyW)\
**Post date:** [April 28, 2004, 3:07am UTC](https://forum.kirupa.com/t/help-with-acceleration-script/49943/1 "2004-04-28T03:07:40Z")

</div>

I am kind of toying with different things in Flash trying to get aquainted with coding and what not.I want to get to the point of making some simple games. I am having trouble coming up with something to make a ball accelerate. Here is what I have to just make the ball move and jump around.

onClipEvent(load){  
var moveSpeed = 15;  
var jumpPower = 30;  
var grav = 4;  
var ysp = 0;  
var jump = false;  
}  
onClipEvent(enterFrame){  
if(Key.isDown(Key.RIGHT) && \_x\<550-\_width/2){

```
    _xscale = 122; 
    _x += moveSpeed;
    if(jump==false){ 
        gotoAndStop(2); 
    } 
}else if(Key.isDown(Key.LEFT) && _x&gt;_width/2){ 

```

\_xscale = -122;  
\_x -= moveSpeed;  
if(jump==false){  
gotoAndStop(2);  
}  
}else if(jump==false){  
gotoAndStop(1);  
}  
if(Key.isDown(Key.UP) && jump==false){  
gotoAndStop(3);  
jump = true;  
ysp = 0;  
ground = \_y;  
}  
if(jump==true){  
\_y = \_y - jumpPower + ysp;  
ysp += grav;  
if(\_y\>ground){  
\_root.bounce\_sound.start();  
ysp = 0;  
gotoAndStop(1);  
\_y = ground;  
jump = false;  
}  
}  
}

That works just fine, but its real bland. I need it to be able to accelerate when I hold down the button and deccelerate once I let go.
