[FMX] random movement tut

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!:slight_smile:

tnx
fusi

[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]

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…:alien: