Tengo un problema y ya llevo algo de tiempo tratando de arreglar pero no puedo.
Lo que quiero hacer es tener multiples moviclips moviendose dinamicamente. Cuando el mouse se acerce los aleje pero continue moviendose.
El problema es que cuando el mouse se acerca mueve al movieclip pero no sigue con la trayectoria.
Esto es lo que tengo:
Código:
Aquí tengo el archivo./*=========================*/ MovieClip.prototype.panicMouse = function(distanz, tempo, besch){ var dist, norm; var xdiff = this._parent._xmouse - this._x; var ydiff = this._parent._ymouse - this._y; var abstand = Math.sqrt(xdiff*xdiff + ydiff*ydiff); var movex, movey; if (abstand < distanz){ var winkel = Math.atan2(ydiff, xdiff); if (besch) tempo = Math.min(tempo, besch*distanz/abstand); this._x -= Math.cos(winkel)*tempo; this._y -= Math.sin(winkel)*tempo; }else{ if(_root.getdistance(this.x, this.y, this.targx, this.targy)>this.speed){ //trace('yes '+_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){ trace('time out'); this.reset(); this.t = 0; } } this._x = this.x; this._y = this.y; } } total = 700 / 6; for (i=1; i<1; i++) { duplicateMovieClip (_root.drop, "circle_"+i, i); _root.drop._x = total * i; //_root.drop._y = total * i; } function createEmptyMovieclip(i){ duplicateMovieClip (_root.drop, "circle_"+i, i); _root.drop._x = total * i; } /*=========================*/ function getdistance(x, y, x1, y1) { var run, rise, total; run = x1-x; rise = y1-y; total = _root.hyp(run, rise); return total; } /*=========================*/ function hyp(a, b) { return (Math.sqrt(a*a+b*b)); } /*=========================*/ MovieClip.prototype.reset = function() { //specify the width and height of the movie width = 952; height = 1000; //------------------- var dist, norm; this.x = this._x; this.y = this._y; this.speed = Math.random()*15+2; 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; };
Espero que alguien me peuda ayudar u orientar
Saludos
http://nuterra10.nuterrallc.com/asse...Background.swf