var xDir = 1;
var yDir = 1;
var xDir2 = 3;
var yDir2 = -2;
var xDirsq = -1;
var yDirsq = 2;
var xDirpe = 1;
var yDirpe = -3;
var maxSpeed = 18;
var speed = new Array(newSpeed(maxSpeed), newSpeed(maxSpeed));
var radius = circle._width * .5;
var radius = square._width * .5;
var radius = pete._width * .5;
//
//
//
function updateFrame() {
// circle boundaries and speed
circle._x += speed[0] * xDir;
circle._y += speed[1] * yDir;
//
if (circle._x < radius) {
circle._x = radius;
xDir *= -1;
speed[0] = newSpeed(maxSpeed);
}
else if (circle._x > Stage.width - radius) {
circle._x = Stage.width - radius;
xDir *= -1;
speed[0] = newSpeed(maxSpeed);
}
if (circle._y < radius) {
circle._y = radius;
yDir *= -1;
speed[1] = newSpeed(maxSpeed);
}
else if (circle._y > Stage.height - radius) {
circle._y = Stage.height - radius;
yDir *= -1;
speed[1] = newSpeed(maxSpeed);
}
circle2._x += speed[0] * xDir2;
circle2._y += speed[1] * yDir2;
//
if (circle2._x < radius) {
circle2._x = radius;
xDir2 *= -1;
speed[0] = newSpeed(maxSpeed);
}
else if (circle2._x > Stage.width - radius) {
circle2._x = Stage.width - radius;
xDir2 *= -1;
speed[0] = newSpeed(maxSpeed);
}
if (circle2._y < radius) {
circle2._y = radius;
yDir2 *= -1;
speed[1] = newSpeed(maxSpeed);
}
else if (circle2._y > Stage.height - radius) {
circle2._y = Stage.height - radius;
yDir2 *= -1;
speed[1] = newSpeed(maxSpeed);
}
square._x += speed[0] * xDirsq;
square._y += speed[1] * yDirsq;
// square boundaries and speed
if (square._x < radius) {
square._x = radius;
xDirsq *= -1;
speed[0] = newSpeed(maxSpeed);
}
else if (square._x > Stage.width - radius) {
square._x = Stage.width - radius;
xDirsq *= -1;
speed[0] = newSpeed(maxSpeed);
}
if (square._y < radius) {
square._y = radius;
yDirsq *= -1;
speed[1] = newSpeed(maxSpeed);
}
else if (square._y > Stage.height - radius) {
square._y = Stage.height - radius;
yDirsq *= -1;
speed[1] = newSpeed(maxSpeed);
}
pete._x += speed[0] * xDirpe;
pete._y += speed[1] * yDirpe;
// pete boundaries and speed
if (pete._x < radius) {
pete._x = radius;
xDirpe *= -1;
speed[0] = newSpeed(maxSpeed);
}
else if (pete._x > Stage.width - radius) {
pete._x = Stage.width - radius;
xDirpe *= -1;
speed[0] = newSpeed(maxSpeed);
}
if (pete._y < radius) {
pete._y = radius;
yDirpe *= -1;
speed[1] = newSpeed(maxSpeed);
}
else if (pete._y > Stage.height - radius) {
pete._y = Stage.height- radius;
yDirpe *= -1;
speed[1] = newSpeed(maxSpeed);
}
}
//
//
function newSpeed(tops) {
var base = tops * .3;
var extra = tops * .3;
return (Math.random() * extra + base);
}
//
// associate a function with the enterFrame event
this.onEnterFrame = updateFrame;