You could use a timer to position the a movieclip and test whether it overlaps by using hitTestObject(object). You let the timer run changing x and y until there is no overlap and then stop it. However, this is ok if you have two or may be 3 clips. When the number is higher you have to test all of them against each other and then it gets complicated.
- The right of the People to create Flash movies shall not be infringed. -
There would be about 6-8 objects I want to place on the stage so a timer, like you say, might be too intensive.
Is there a way I could use a grid type system and assign each object to its own grid (or area) on the stage.
The select at random, which objects to display?
That way there would be no chance of overlapping as each objects would only have one possible place it could be located, which would be unique to that object.
Here is a class (GridMaker) that creates a grid http://www.flashscript.biz/flashas3/biz/index.html
However, usually you can only make a grid from one type of object. So one possibility is to create a grid of containers.
- The right of the People to create Flash movies shall not be infringed. -
If an x bigger than 100 would cause overlap, I would set the limit as 100 (Math.random()*100). I don't think you can have the smaller exception unless you do an if statement. Another possibility is to create an array with numbers and then use Math.random on the array. Then you can control easily the lower and upper limit.
- The right of the People to create Flash movies shall not be infringed. -