# Flash as2 Please, check my code can't find the error

**URL:** <https://forum.kirupa.com/t/flash-as2-please-check-my-code-cant-find-the-error/331794>\
**Category:** flash\
**Created:** [October 22, 2013, 5:54pm UTC](https://forum.kirupa.com/t/flash-as2-please-check-my-code-cant-find-the-error/331794 "2013-10-22T17:54:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jason\_Scholz](https://avatars.discourse-cdn.com/v4/letter/j/53a042/32.png) [@Jason\_Scholz](https://forum.kirupa.com/u/Jason_Scholz)\
**Post date:** [October 22, 2013, 5:54pm UTC](https://forum.kirupa.com/t/flash-as2-please-check-my-code-cant-find-the-error/331794/1 "2013-10-22T17:54:38Z")

</div>

Well, the code works “almost” flawlessly. Problem is, the “Hero” keeps falling through the Ground movieclip. What am I missing? Here is the code:

```php
onClipEvent(load)
{
    speed = 5;
    gravity = 0;
    r = _height/2;
    jumping = false;
    jumpHeight = 10;
}

onClipEvent(enterFrame)
{    
    if(Key.isDown(Key.UP) && !jumping)
    {
        gravity = -jumpHeight;
        jumping = true;
    }
    if(!_root.Ground.hitTest(_x, _y, true))
    {
        gravity ++;
        _y += gravity;
    }
    else
    {
        jumping = false;
        gravity = 0;
    }
    while(_root.Ground.hitTest(_x, _y-1+r, true))
    {
        jumping = false;
        _y --;
    }
    if(Key.isDown(Key.RIGHT))
    {
        _x += speed;
        gotoAndStop(3);
    }
    else if(Key.isDown(Key.LEFT))
    {
        _x -= speed
        gotoAndStop(2)
    }
    else
    {
        gotoAndStop(1);
    }
}

```
