i’m trying to do an infinate loop for my m.clip.the looping part does not want to loop…it loops back to my firrst frame even though there are two same picture in the movie clip…here’s a sample of what i use for the infinate loop script…
[COLOR=Blue]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+bb));
}
MovieClip.prototype.reset = function() {
width = 480;
height = 280;
var dist, norm;
this.x = this._x;
this.y = this._y;
this.speed = Math.random()*4+2;
this.targx = Math.random()*width+10;
this.targy = Math.random()*height+10;
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>1000) {
this.reset();
this.t = 0;
}
}
this._x = this.x;
this._y = this.y;
}
stop();[/COLOR]
These script are put on the top layer.And this following script is for the movie clip.
[COLOR=Blue]onClipEvent (load) {
xcenter = 250;
speed = 1/10;
}
onClipEvent (enterFrame) {
if (_root._ymouse>30 && _root._ymouse<280) {
var distance = _root._xmouse-xcenter;
_x += (distance*speed);
if (_x>0) {
_x = -703;
}
if (_x<-703) {
_x = 0;
}
}
}[/COLOR]
i dunno why it does not work…so anyone who knows what wrong…pleease do kelp…