# Random movement within a MC

**URL:** https://forum.kirupa.com/t/random-movement-within-a-mc/158932
**Category:** flash
**Created:** [August 12, 2005, 8:34pm UTC](https://forum.kirupa.com/t/random-movement-within-a-mc/158932 "2005-08-12T20:34:36Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![xposed](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/xposed/32/1641_2.png) [@xposed](https://forum.kirupa.com/u/xposed)
#### Post date: [August 12, 2005, 8:34pm UTC](https://forum.kirupa.com/t/random-movement-within-a-mc/158932/1 "2005-08-12T20:34:36Z")

</div>

the following is in regards to the random movement tutorials. In an attempt to expand on what I have learned, I’ve given it my best attempt to get the movement to stay within the confines of the symbol(movieclip border) in which I have the dot symbol placed. As opposed to the whole entire stage area for as in the tutorial.

I get a wierd effect where it goes way of stage and the movement is just up and down over and over again.

My initial reaction is that I may need to modify this section of code in order to obtain the animation inside a movieclip. I’m just not sure what to change =D

onClipEvent (load) {  
//data you may want to change  
width = 300;  
height = 200;  
speed = Math.round(Math.random()\*2)+1;  
//initial positions  
x = Math.random()\*width;  
y = Math.random()\*height;  
this.\_x = x;  
this.\_y = y;  
x\_new = Math.random()\*width;  
y\_new = Math.random()\*height;  
}

Thank you for any help!
