# Need help with vibration script for creating earthquake

**URL:** <https://forum.kirupa.com/t/need-help-with-vibration-script-for-creating-earthquake/257760>\
**Category:** flash\
**Created:** [April 16, 2008, 9:06pm UTC](https://forum.kirupa.com/t/need-help-with-vibration-script-for-creating-earthquake/257760 "2008-04-16T21:06:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bluepanda](https://avatars.discourse-cdn.com/v4/letter/b/94ad74/32.png) [@Bluepanda](https://forum.kirupa.com/u/Bluepanda)\
**Post date:** [April 16, 2008, 9:06pm UTC](https://forum.kirupa.com/t/need-help-with-vibration-script-for-creating-earthquake/257760/1 "2008-04-16T21:06:01Z")

</div>

Hello everyone! 🙂

I’m in the process of creating an earthquake that takes place in an office setting. This will require the entire room to rumble. I found the following script that makes things rumble fairly well when I slap it on a movie clip:

```auto
onClipEvent (load) {
    //movie width/height
    height = 200;
    width = 300;
    //------------------------//
    //makes everything random //
    //------------------------//

    //setting initial position
    cx = this._x;
    cy = this._y;
}
onClipEvent (enterFrame) {
    //causes the object to be offset
    this._x = cx+(1+Math.random()*5); //The "5" controls the amount of rumble
    this._y = cy+(Math.random()*5); //The "5" controls the amount of rumble
}

```

However, I need a way to gracefully fade the rumbling in, and eventually fade it out when the earthquake stops. Does anyone know the best way to accomplish such a thing? It could either be some kind of hardcoded number that corresponds with the length of the earthquake, or even something that is timeline based. If anyone has done anything like this, please help! 🙂

Thank you,

-Eric
