-
array referencing question
Ok, i thought I had this figured out, but no.
Let's say I have an array : _root.stuff.thingy.myArray
it contains 10 names for MCs running around in _root.stuff ... MC1, MC2, etc...
Let's say there's a dude trying to use his teeth to eat those MCs: _root.dude.teeth
when i make the dude's teeth close, I want to do a for loop hitTest on all 10 MCs, so i started writing:
code: for(i=0;i<10;i++){
if(_root.dude.teeth.hitTest(_root.stuff.myArray[i]) {
_root.stuff.myArray[i].gotoAndPlay("open");
}
}
but this obviously won't work because it doesn't target the array. How do I write this?
-
hmm, with that code you are only really targeting something like code: if(_root.dude.teeth.hitTest(MC1) {
on each iteration, if you use a direct path like _root[_root.stuff.myArray[i]] you are targetting _root.MC1 which is more likely to be the correct path. (assuming MC1 is on the _root)
[m]
-
MC1 is in _root.stuff
the array with it's name is in _root.stuff.thingy.myArray
-
the thing is, I know how to get the name of the MC out of the array, but how do I get that name into _root.dude.teeth.hitTest(the name of the MC properly targeted)
-
try code: _root[_root.stuff[_root.stuff.myArray[i]];
-
thanks for the help. it was the bracketing I didn't know about. Yasunobu gave me a similar answer
_root.dude.teeth.hitTest(_parentMC[_root.stuff.myArray[i]])
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|