# Sprites & Gravity

**URL:** <https://forum.kirupa.com/t/sprites-gravity/330957>\
**Category:** flash\
**Created:** [April 16, 2013, 10:22pm UTC](https://forum.kirupa.com/t/sprites-gravity/330957 "2013-04-16T22:22:29Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![DeadManJoe33](https://avatars.discourse-cdn.com/v4/letter/d/90db22/32.png) [@DeadManJoe33](https://forum.kirupa.com/u/DeadManJoe33)\
**Post date:** [April 16, 2013, 10:22pm UTC](https://forum.kirupa.com/t/sprites-gravity/330957/1 "2013-04-16T22:22:29Z")

</div>

Ok so the issue I’m having is that I can’t get the gravity working for this sprite. I tried attaching the script I have but I’ll post it here too,

package  
{  
import flash.display.MovieClip  
import flash.events.Event  
import flash.events.KeyboardEvent

public class DocumentMain extends MovieClip  
{  
public var \_startMarker:StartMarker;  
public var \_player:Player;  
public var \_platform:Platform;

private var \_vx:Number;  
private var \_vy:Number;

public function DocumentMain() :void  
{  
// assign default values  
\_startMarker.visible = false;  
\_vx = 0;  
\_vy = 0;

// set focus for keyboard input  
stage.focus = stage;

// add event listeners  
this.addEventListener(Event.ENTER\_FRAME, enterFrameHandler);  
stage.addEventListener(KeyboardEvent.KEY\_DOWN, keyDownHandler);  
stage.addEventListener(KeyboardEvent.KEY\_UP, keyUpHandler);  
}

private function enterFrameHandler(e:Event):void  
{  
// gravitate the player  
\_vy += 2;

```
// move the player
_player.x += _vx;
_player.y += _vy;

// process collisions
processCollisions();

// scroll the stage
scrollStage();

```

}

private function keyDownHandler(e:KeyboardEvent):void  
{  
}

private function keyUpHandler(e:KeyboardEvent):void  
{  
}

private function processCollisions():void  
{  
}

private function scrollStage():void  
{  
}  
}  
}  
Thanks!
