Hello -
I am having trouble stopping my random movement code. What I would like to do is make the random movement stop wherever the mc’s are and slide to a specific location using “myClickedBtnFunction()”. Please help!
This is on each of the MC’s that I have calling the code from the main timeline.
[COLOR=red]onClipEvent(enterframe) {
move();
}[/COLOR]
[COLOR=red]on (rollOver) {
this._parent.btn = “link1”
this._parent.myRolloverBtnFunction()
}
on (rollOut) {
this._parent.btn = “link1”
this._parent.myRolloutBtnFunction()
}
on (release) {
this._parent.btn = “link1”
this._parent.myClickedBtnFunction ()
}[/COLOR]
[COLOR=#ff0000][/COLOR]
[COLOR=black]On the main timeline I have the following code
[/COLOR]
[COLOR=red]function getdistance(x, y, x1, y1) {
var run, rise;
run = x1-x;
rise = y1-y;
return (_root.hyp(run, rise));
}
function hyp(a, b) {
return (Math.sqrt(aa+b*b));
}
MovieClip.prototype.reset = function() {
width = 615;
height = 514;
var dist, norm;
this.x = this._x;
this.y = this._y;
this.speed = .5;
this.targx = Math.random()*width;
this.targy = Math.random()*height;
dist = _root.getdistance(this.x, this.y, this.targx, this.targy);
norm = this.speed/dist;
this.diffx = (this.targx-this.x)*norm;
this.diffy = (this.targy-this.y)norm;
};
MovieClip.prototype.move = function() {
if (_root.getdistance(this.x, this.y, this.targx, this.targy)>this.speed) {
this.x += this.diffx;
this.y += this.diffy;
} else {
this.x = this.targx;
this.y = this.targy;
if (!this.t) {
this.t = getTimer();
}
if (getTimer()-this.t>00000001) {
this.reset();
this.t = 1;
}
}
this._x = this.x;
this._y = this.y;
};[/COLOR]
[COLOR=#ff0000][/COLOR]
[COLOR=#ff0000][/COLOR]