Question

I have movieClips namely rec1, rec2, rec3, rec4...

Then, I would addChild another movieclip(circle_mc) to those rec MovieClips.

I want to use the hitTestObject... Something like this:

circle_mc.hitTestObject(this["rec" + numStringTarget])

If I specify number on the numStringTarget variable, I can only attach to one of the "rec" movieclips. What I want is the capability of circle_mc to be added on any "rec" movieclips. Is there any way to use wildcard? Or any way to solve it?

I want the code to become like this:

circle_mc.hitTestObject(contains String "rec") then addChild..

I hope someone can solve it or just give me some helpful links to read about. Thanks in advance.

I do not want to set all these statements this way:

circle_mc.hitTestObject(rec1);
circle_mc.hitTestObject(rec2);
circle_mc.hitTestObject(rec3);
circle_mc.hitTestObject(rec4);

what if I have a hundreds or thousands... I want to test if the movieclip, as long as it has word "rec" on its instance name, it will be tested.

Or it could be in another situation. My circle_mc is draggable. Then when it hit another movieclip on stage, is there any way to show up the instance name hit by the circle_mc?

Was it helpful?

Solution

for (var i:int = 0; i < _totalRecObjects; ++i) {
   circle_mc.hitTestObject(this["rec" + i]);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top