You have two circles, right? And you have two variables, right and left, to tell you whether the circles are moving right or left. The two variables that you have, though, essentially track just one property, and could have been done in just one variable.
So the problem is that you are tracking just one property (call it direction). But you are using that one property for both circles. Each circle should really have its own property, so that it "knows" what direction it's going.
Here's one way of doing it. In your initial for loop, give each circle a dynamic property called dir (for direction). The dir property can have a value of either 1 or -1. A value of 1 will cause it to move right, and a value of -1 will cause it to move left. Then, rather than use an if statement, all you have to do is multiply this dir property by the speed, and you will get either a positive or negative speed value as a result. When you add this value to the circle's x, if the value added is negative, it will move left. If it is positive, it will move right:
ActionScript Code:
var circles:Array = new Array();
var quantity:int = 2;
var maxX:Number = stage.stageWidth - 40;
var minX:Number = 0;
var speed:Number = 2;
for (var i:uint = 0; i < quantity; i++)
{
circles[i] = new Circle();
addChild(circles[i]);
circles[i].x = Math.random() * stage.stageWidth;
circles[i].y = Math.random() * stage.stageHeight;
circles[i].dir = 1; //dynamic property, 1 = right, -1 = left
}
addEventListener(Event.ENTER_FRAME , movement);
function movement(e:Event):void
{
for (var i:uint = 0; i < circles.length; i++)
{
if (circles[i].x >= maxX)
{
circles[i].dir = -1;
}
if (circles[i].x <= minX)
{
circles[i].dir = 1;
}
circles[i].x += circles[i].dir * speed;
}
}
I also made the above more dynamic, so that you can just change the quantity variable to a higher number to create more circles. There's no real reason for manually creating mc1, mc2, etc, and then manually putting them into an array like you were doing.