# Random motion and attachmovieclips

**URL:** <https://forum.kirupa.com/t/random-motion-and-attachmovieclips/189358>\
**Category:** flash\
**Created:** [June 1, 2006, 9:51pm UTC](https://forum.kirupa.com/t/random-motion-and-attachmovieclips/189358 "2006-06-01T21:51:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![thesainter](https://avatars.discourse-cdn.com/v4/letter/t/b782af/32.png) [@thesainter](https://forum.kirupa.com/u/thesainter)\
**Post date:** [June 1, 2006, 9:51pm UTC](https://forum.kirupa.com/t/random-motion-and-attachmovieclips/189358/1 "2006-06-01T21:51:57Z")

</div>

I’m trying to combine these two tutorials:  
[http://www.kirupa.com/developer/actionscript/multiDimArrays\_attach.htm](http://www.kirupa.com/developer/actionscript/multiDimArrays_attach.htm)

and random motion:  
[http://www.kirupa.com/developer/actionscript/random\_motion.htm](http://www.kirupa.com/developer/actionscript/random_motion.htm)

but how?  
I want the attached movies to float around but i just can’t.  
Here is the code.

[Actionscript]

//Array with all our information  
memberInfo = [[“Kirupa”, “Flashing (MX) complete strangers in 32-bit color.”, “[http://www.kirupa.com/forum/member.php?u=1](http://www.kirupa.com/forum/member.php?u=1)”], [“B.Rich”, “Basketball, Golf, Web Media.”, “[http://www.kirupa.com/forum/member.php?u=4513](http://www.kirupa.com/forum/member.php?u=4513)”], [“Senocular”, “Fun stuff, like Flash”, “[http://www.kirupa.com/forum/member.php?u=2867](http://www.kirupa.com/forum/member.php?u=2867)”]];  
//Starting x & y values  
var xPos = 150;  
var yPos = 60;  
//For loop to attach our container movieclip and pass the array information  
for (i=0; i\<memberInfo.length; i++) {  
//attach the container clip  
attachMovie(“container”, “new”+i, i, {\_x:xPos, \_y:yPos});  
//onLoad = function() {  
//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[“new”+i].\_x = x;

```
this["new"+i]._y = y;

x_new = Math.random()*width;
trace(x_new)

y_new = Math.random()*height;

//increase the y postion each time
//yPos += this["new"+i]._height+5;
//add the information
this["new"+i].name.text = memberInfo*[0];
this["new"+i].interest.text = memberInfo*[1];
this["new"+i].link = memberInfo*[2];

```

}

onEnterFrame = function() {  
//x movement  
trace(“ok”)  
if (x\_new \> this[“new”+i].\_x) {  
sign\_x = 1;

```
} else {
    sign_x = -1;
}
trace(sign_x)

dx = Math.abs(x_new - this["new"+i]._x);
if ((dx&gt;speed) || (dx&lt;-speed)) {
    this["new"+i]._x += sign_x*speed;
} else {
    
    x_new = Math.random()*width;
}
//y movement

if (y_new &gt; this["new"+i]._y) {
    sign_y = 1;
} else {
    sign_y = -1;
}

dy = Math.abs(y_new - this["new"+i]._y);
if ((dy&gt;speed) || (dy&lt;-speed)) {
    this["new"+i]._y += sign_y*speed;
} else {
    y_new = Math.random()*height;
}

```

}

[/Actionscript]

can anyone see what I have to do to get the attached movies moving around? please?..🙂

file is attached.
