# Help with my Gravity Code

**URL:** <https://forum.kirupa.com/t/help-with-my-gravity-code/205566>\
**Category:** programming\
**Created:** [October 30, 2006, 9:25pm UTC](https://forum.kirupa.com/t/help-with-my-gravity-code/205566 "2006-10-30T21:25:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Signy](https://avatars.discourse-cdn.com/v4/letter/s/5e9695/32.png) [@Signy](https://forum.kirupa.com/u/Signy)\
**Post date:** [October 30, 2006, 9:25pm UTC](https://forum.kirupa.com/t/help-with-my-gravity-code/205566/1 "2006-10-30T21:25:35Z")

</div>

hello all.

I’ve come up with this little piece of simple gravity code

```auto
    
    
    var yfall = 0
    var grav = 0.3
    
    function onEnterFrame(){
        
        yfall = yfall + grav
        
        if(_y + yfall > 755){
            yfall =- yfall*0.65
            }
        _y = _y + yfall
        
        }
        
}

```

This is in a seperate .as file to my movie and as items from my movie are randomley generated from an array these physics properties are then applied dynamically to the randomley generated clips.

What i would really like to do is have the clips explode out in a set arc shooting upwards befor being pulled down by gravity.

Two questions:

1. How would i get the clips to go up befor the physics code kicks in?
2. How do i get the clips to fall at a random angle?

I thought the random angle code might look somthing like this:

```auto

        random:Number = 270*(Math.PI/180);

```

But that dosent seem to work.

Any ideas?

Thanks.
