# \[FMX\] random movement tut

**URL:** <https://forum.kirupa.com/t/fmx-random-movement-tut/26111>\
**Category:** flash\
**Created:** [July 19, 2003, 5:37pm UTC](https://forum.kirupa.com/t/fmx-random-movement-tut/26111 "2003-07-19T17:37:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fusi](https://avatars.discourse-cdn.com/v4/letter/f/cdc98d/32.png) [@fusi](https://forum.kirupa.com/u/fusi)\
**Post date:** [July 19, 2003, 5:37pm UTC](https://forum.kirupa.com/t/fmx-random-movement-tut/26111/1 "2003-07-19T17:37:20Z")

</div>

hello!

i successfully got the random tuorial working. now i’m lokking for a function for a button to stop and start the random movement at will. i dont want to change frames, im just need a function to break the movement and make the mcs stay put…

i hope you can help!🙂

tnx  
fusi

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 19, 2003, 5:53pm UTC](https://forum.kirupa.com/t/fmx-random-movement-tut/26111/2 "2003-07-19T17:53:10Z")

</div>

[AS]MovieClip.prototype.moveIf = function(move){  
this.onEnterFrame = function(){  
if(move == true){  
move();  
}  
}  
}  
//example usage

theClip.moveIf(1 == 1);

//in this example theClip will always move. you can use any conditional statement though.  
[/AS]

or with a button:  
[AS]  
//enter the prototype above.

//code on main timeline:

toggle\_btn.onRelease = function(){  
if(move == undefined){  
var move = true;  
}  
move = !move  
}

randomMove.moveIf(move);  
[/AS]

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 19, 2003, 6:41pm UTC](https://forum.kirupa.com/t/fmx-random-movement-tut/26111/3 "2003-07-19T18:41:27Z")

</div>

hello njs!

tnx 4 that!

would that button work if the move-function werent in the mc’s but in the main-timeline aswell?

i attached a fla so you can see what i mean.

and another problem i guess is that i create the mc’s by a for-loop…and i want to stop em moving and stay put when i click on them…so i think i need to put the “stop-order” somewhere in the mcs themselves.

i hope you understand what i mean…👽
