# \[FMX\]Function random movement

**URL:** <https://forum.kirupa.com/t/fmx-function-random-movement/108267>\
**Category:** Uncategorized\
**Created:** [April 23, 2004, 8:14am UTC](https://forum.kirupa.com/t/fmx-function-random-movement/108267 "2004-04-23T08:14:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dboers](https://avatars.discourse-cdn.com/v4/letter/d/bbe5ce/32.png) [@dboers](https://forum.kirupa.com/u/dboers)\
**Post date:** [April 23, 2004, 8:14am UTC](https://forum.kirupa.com/t/fmx-function-random-movement/108267/1 "2004-04-23T08:14:15Z")

</div>

I have the following clipEvent on a movieclip called square:

onClipEvent (enterFrame) {  
xmove = (xpos-this.\_x)/5;  
this.\_x += xmove;  
}

And the following framecode in the same keyframe as square:

\_root.square.xpos = Math.round(Math.random()\*550);

Now I want to use this information in a function so I can control more than just one clip.

How should this function look like?
