# Function + variables all in actions frame

**URL:** <https://forum.kirupa.com/t/function-variables-all-in-actions-frame/250991>\
**Category:** Uncategorized\
**Created:** [February 4, 2008, 1:25pm UTC](https://forum.kirupa.com/t/function-variables-all-in-actions-frame/250991 "2008-02-04T13:25:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![TooRomeo](https://avatars.discourse-cdn.com/v4/letter/t/7bcc69/32.png) [@TooRomeo](https://forum.kirupa.com/u/TooRomeo)\
**Post date:** [February 4, 2008, 1:25pm UTC](https://forum.kirupa.com/t/function-variables-all-in-actions-frame/250991/1 "2008-02-04T13:25:46Z")

</div>

The following code is what I have in an actions frame:

```auto

function FLOAT_engine() {
    this._x = this.cenX+Math.sin(this.angleX)*this.rangeX;
    this._y = this.cenY+Math.sin(this.angleY)*this.rangeY;
    this.angleX += this.xspeed;
    this.angleY += this.yspeed;
}
floaty.onEnterFrame = FLOAT_engine;
floaty2.onEnterFrame = FLOAT_engine;
etc.

```

And in my movieclip (floaty) I have the variables:

```auto

onClipEvent (load) {
    cenX = this._x;
    cenY = this._y;
    angleX = 0;
    angleY = 0;
    rangeX = 5;
    rangeY = 5;
    xspeed = .05;
    yspeed = .06;
}

```

How would I got about re-writing this code so it is all in the actions frame? The way that I have it set up now, I’d have to paste the variables into every movieclip. It would be a pain if I ever wanted to change the values. ;( Thanks in advance.
