a me così funge bene
codice:
// larghezza, altezza clip
// origine x,y e dimensioni 'area di movimento'
// posizione iniziale clip
mcLar = mc._width;
mcHal = mc._height;
areaX = 300;
areaY = 400;
areaLar = 40;
areaHal = 80;
mcStartX = (areaX+areaLar)/2-mcLar/2;
mcStartY = (areaY+areaHal)/2-mcHal/2;
mc._x = mcStartX;
mc._y = mcStartY;
//
// funzione muovi clip random
MovieClip.prototype.moveRandom = function(nomeClip, posX, posY, speed) {
this[nomeClip].onEnterFrame = function() {
with (this) {
_x += (posX-_x)/speed;
_y += (posY-_y)/speed;
}
};
};
//
// chiamata funzione ogni 1 sec.
setInterval(function () {
moveRandom("mc", (random((areaX+areaLar)-mcLar))+60, (random((areaY+areaHal)-mcHal))+70, 5);
}, 1000);
setInterval(function () {
moveRandom("mc1", (random((areaX+areaLar)-mcLar))+60, (random((areaY+areaHal)-mcHal))+70, 5);
}, 1000);
ciao