A continuacion pongo el codigo que estoy usando:
Código :
var vyB1:Number = -1; var vxB1:Number = -13; var AreaB1:Number = Boss1.width; stage.addEventListener(Event.ENTER_FRAME, mueveYPegaSt9B1); function mueveYPegaSt9B1(e: Event):void { vyB1 = vyB1; vxB1 = vxB1; Boss1.x = Boss1.x + vxB1; Boss1.y = Boss1.y + vyB1; if (Boss1.y + AreaB1 > marcoSt9.height) { vyB1 = - vyB1; } else if (Boss1.y-AreaB1<0) { vyB1 = - vyB1; } if (Boss1.x + AreaB1 > marcoSt9.width) { vxB1 = - vxB1; } else if (Boss1.x-AreaB1<0) { vxB1 = - vxB1; } var Boss1x:Number; var Boss1y:Number; var bXB1:Number; var bYB1:Number; var distanciaBb:Number; var areaBoss:Number = Boss1.width; var radioBb1:Number = b.width / 2; var areasByb:Number = areaBoss + radioBb1; Boss1x = Boss1.x; Boss1y = Boss1.y; bXB1 = b.x; bYB1 = b.y; distanciaBb = (((bXB1 - Boss1x) * (bXB1 - Boss1x)) + ((bYB1 - Boss1y) * (bYB1 - Boss1y))); distanciaBb = Math.sqrt(distanciaBb); if (distanciaBb<areasByb) {... }
Si alguien me pudiese ayudar...
Grasias