For Loop function
Hi,
Can anyone modify this code to for loop? I have searched in this forum but found nothing. I comented on some similar post, but no respon.
//I want to add movieclips named mc1, mc2, mc3, mc4.
this.stageW = 550;
this.stageH = 400;
this.speed = 7;
if(!this.alreadyStarted){
this.alreadyStarted = true;
randomNumbersF.bind(this)();
createjs.Ticker.addEventListener("tick", updateF.bind(this));
}
function randomNumbersF(){
this.randX = Math.floor(Math.random()*this.stageW);//scaled to the size of the screen
this.randY = Math.floor(Math.random()*this.stageH);
this.r = Math.sqrt( (this.mc0.y-this.randY)*(this.mc0.y-this.randY) + (this.mc0.x-this.randX)*(this.mc0.x-this.randX) );
linearEqF.bind(this)();
}
function linearEqF(){
this.inc = 1;
this.theta = Math.atan2( this.randY-this.mc0.y, this.randX-this.mc0.x );
}
function updateF(){
this.mc0.x += this.speed*Math.cos(this.theta);
this.mc0.y += this.speed*Math.sin(this.theta);
if(this.inc*this.speed >= this.r){
randomNumbersF.bind(this)();
}
this.inc++;
};
