frame(s)
private function frame(event:Event):void {
var h:Number = systemManager.stage.height;
var w:Number = systemManager.stage.width;
for(var i:uint = 0; i < smax; i++) {
vx = avx[i]; vy = avy[i];
var dx:Number = 0; //Math.random() * 2 - 1;
var dy:Number = 0; //Math.random() * 2 - 1 ;
vx += dx; vy += dy + gravity;
var s:Number = w/800;
var left:Number = 0;
var right:Number = myVid.width;
var top:Number = 0;
var bottom:Number = myVid.height;
oval.centerX = right/2;
oval.centerY = bottom/2;
oval.radiusX = right/3;
oval.radiusY = bottom/4;
// for(var i:uint = 0; i < 2; i++) {
var ball:Sprite = sprites[i];
var bounds:Rectangle = ball.getBounds(myVid);
ball.x += vx;
ball.y += vy;
var cx:Number = bounds.x + bounds.width/2;
var cy:Number = bounds.y + bounds.height/2;
for(var j:uint = i; j < smax; j++) {
var other:Rectangle = sprites[j].getBounds(myVid);
var ocx:Number = other.x + other.width/2;
var ocy:Number = other.y + other.height/2;
if (((bounds.right > other.left && cx < other.left) && ((bounds.bottom > other.top && cy < other.top) || (bounds.top < other.bottom && cy > other.bottom)) ) ||
((bounds.left < other.right && cx > other.right) && ((bounds.bottom > other.top && cy < other.top) || (bounds.top < other.bottom && cy > other.bottom))) )
{
var ddx:Number = cx - ocx;
var ddy:Number = cy - ocy;
if (ddx*ddx < ddy*ddy) {
vx *= bounce; avx[j] *= bounce;
ball.x += 3 * vx;
} else { vy *= bounce; avy[j] *= bounce;
ball.y += 3 * vy;
}
}
}
if((bounds.right > right) || (bounds.left < left))
{
vx *= bounce;
ball.x += 5 * vx;
}
if((bounds.bottom > bottom) || (bounds.top < top))
{
vy *= bounce;
ball.y += 5 * vy;
}
avx[i] = vx; avy[i] = vy;
}
}