You could place the circles dynamically in the first place, either totally random, and you'd get elements overlapping, or place them in a grid with a small random offset. Maybe have a separate fla that would generate the circles again and again on click until you're happy with a configuration then spit out the actionscript code for that using a key. Kind of like a quick and dirty level editor.
var circlesNum:int = 20;
var circleRadius:Number = 10;
var circles:Array;
var row:int = 4;
var col:int = 5;
var space:int = 5;
var randomOffset:int = 5;
var randomShift:Number;
function generateCircles(event:MouseEvent = null):void{
circles = [];
while(numChildren > 0) removeChildAt(0);
for(var i:int = 0 ; i < circlesNum; i++){
var circle:Shape = new Shape();
circle.graphics.lineStyle(1);
circle.graphics.drawCircle(0, 0, circleRadius);
circle.name = 'circle'+i;
randomShift = Math.random() * randomOffset - randomOffset * .5;
circle.x = ((circleRadius * 2 +space) * (i % col)) + randomShift;
circle.y = ((circleRadius * 2 +space) * (i % row)) + randomShift;
circles.push(circle);
addChild(circle);
}
}
function generateCode(event:KeyboardEvent = null):void {
var code:String = 'var circles:Array = [';
for(var i:int = 0 ; i < circlesNum; i++){
if(i < circlesNum-1) code += '{name: ' + circles[i].name + 'x: ' + circles[i].x + ',y: ' + circles[i].y + '},\n';
else code += '{name: ' + circles[i].name + 'x: ' + circles[i].x + ',y: ' + circles[i].y + '}];';
}
trace(code);
}
stage.addEventListener(MouseEvent.MOUSE_DOWN, generateCircles);
stage.addEventListener(KeyboardEvent.KEY_DOWN, generateCode);
You could name each circle movie clip instance and use actionscript to get the coordinates.
//assuming circles is a movieclip containing all your circles
var code:String = 'var circles:Array = [';
for(var i:int = 0 ; i < circles.numChildren; i++){
if(i < circles.numChildren-1) code += '{name: ' + circles.getChildAt(i).name +'x: ' + circles.getChildAt(i).x + ',y: ' + circles.getChildAt(i).y + '},';
else code += '{name: ' + circles.getChildAt(i).name +'x: ' + circles.getChildAt(i).x + ',y: ' + circles.getChildAt(i).y + '}];';
}
trace(code);
If you only need the X/Y of each circle, you can use JSFL(javascript flash) to loop through your circles and spit out the coordinates.
Here is a sample:
var doc = fl.getDocumentDOM();
var sel = doc.selection;
var selStr = 'var circles:Array = [';
if(sel){
var elNum = sel.length;
for(var i = 0 ; i < elNum ; i++){
if(i < elNum-1) selStr += '{name: '+ sel[i].name +', x: ' + sel[i].x + ',y:' + sel[i].y + '},';
else selStr += '{name: '+ sel[i].name +', x: ' + sel[i].x + ',y:' + sel[i].y + '}];';
}
fl.trace(selStr);
}
Go to File > New > Flash Javascript File
and paste that. You can save it as GetSelectionXY.jsfl in the Commands folder and then assign a keyboard shortcut if you find this handy.
Otherwise, select your circles (could be handy to have all of them in one layer and just select the layer) and run the command(using the playbutton/arrow).
It should spit something like:
var circles:Array = [{name: c1, x: 286.95,y:172},{name: c1, x: 180.95,y:320},{name: c1, x: 92.95,y:126},{name: c1, x: 184.95,y:190},{name: c1, x: 392.95,y:112},{name: c1, x: 316.95,y:226},{name: c1, x: 84.95,y:207},{name: c1, x: 84.95,y:85}];
in the output panel.
Easiest version would probably be with jsfl, you could just use DrawingObjects, no movie clips, just move them about then hit the magic shorcut key.
The more flexible version would be the mini-editor grid thingy.
HTH