Hello, I'm trying to do that, four mc's that I have on stage that have a startDrag effect, have repulsion between them to avoid that they overlap each other. I'm trying this:
Code:
addEventListener(Event.ENTER_FRAME, avoidTouch);
var thresh:Number = 1111;
function avoidTouch(event:Event):void {
var distx: int = menu.b1.x - mouseX;
var disty: int = menu.b1.y - mouseY;
var dist:Number = Math.sqrt(distx*distx + disty*disty);
trace (dist);
if(dist < thresh){
menu.b1.x = mouseX + thresh*distx/dist;
menu.b1.y = mouseY + thresh*disty/dist;
}
}
But it only works with the mouse and I want to do with mc's.
Someone could tell me if there is another solution for this.
Thank you.