# Floating a mc

**URL:** <https://forum.kirupa.com/t/floating-a-mc/293336>\
**Category:** flash\
**Created:** [July 27, 2009, 5:24pm UTC](https://forum.kirupa.com/t/floating-a-mc/293336 "2009-07-27T17:24:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![butbeautiful](https://avatars.discourse-cdn.com/v4/letter/b/fbc32d/32.png) [@butbeautiful](https://forum.kirupa.com/u/butbeautiful)\
**Post date:** [July 27, 2009, 5:24pm UTC](https://forum.kirupa.com/t/floating-a-mc/293336/1 "2009-07-27T17:24:16Z")

</div>

I need to float movieclips and they only move like 2-5 pixels each time off the x or y axis.

I got the codes right but now I need them to start in the stated .\_x and .\_y instead of being at random.

It would even be better if these codes can be also controlled by mouse movement but I doubt it’s possible because it’s being controlled by onClipEvent already?

thanks for the help in advance!

```php
onClipEvent(load) {
        acceleration = 10
        newpos = function () {
        ranx = Math.round((Math.random ()*10));
        rany = Math.round((Math.random ()*10));
        }
        newpos();
}

onClipEvent(enterFrame) {
        this._x += ((ranx-this._x)/acceleration);
        this._y += ((rany-this._y)/acceleration);
        if (Math.round(this._x) == ranx || Math.round(this._y) == rany) {
        newpos();
        }
}

```
