why doesn't hitTest work?
I have implemented three for loops for the hit Test and I have set the condition as "if the object has detected a collision against another object it will be shift to the right". However the overlapping still occurs... should I implement 7 for loops for it? Thank you
I don't know what you are doing for whatever loops you implement, but I don't think quantity is the issue, moreso intelligence (or lack of)... nothing personal intended, I'm talking about the intelligence you build into the system. You could move a planted piece in any direction and continue to have collisions as you move from atop one piece onto another.
What you might think about doing instead is making the system aware of where it can no longer plant objects based on where each item is planted and how much area each occupies. So as you add items, you add to a list that identifies which areas (ranges of x and y locations) must be excluded from the random selections.
I haven't thought this thru beyond the concept, so I can't say it is without complications.
kGlad can likely provide you with a clever solution in any case.
you only need to loop through each pair of movieclips so would use, at most, two nested for-loops. in this situation, though you only need one for-loop:
var mcA:Array = ; // array of your currently added movieclips
var mcNum:Number = 11; // number of non-overlapping movieclips to add
// code to add a randomly placed movieclip
mcA.push(the new movieclip);
// there's no checking to see if you're trying to do something stupid like trying something that's impossible