I concur. You just can't have two mcs on the same depth in Flash. When you use a repeat loop similar to my code, don't forget to switch the shape flag on (see code). This way you'll avoid hitting on empty bits in the rect (that's why I was using circles to test my theory - the bounding rect wasn't hit, just the circles themselves). Then, the _very first time_ you get a hit, you know that you're at the highest depth. Stop the loop and recurse into the clip to check for children. The _fist time_ you get a hit there, stop and check for children again, etc. The first clip to score a hit, which doesn't have any more children that also score a hit, is your dear uncle bob.
Karina > -----Original Message----- > From: Joshua Sera [mailto:[EMAIL PROTECTED] > Sent: 08 February 2007 07:49 > To: Flashcoders mailing list > Subject: Re: [Flashcoders] determining which object is > displayed at agivenpoint > > The only case in which depth would be identical for two > movieclips is if they both were contained in different parent > movieclips. > > In that case, check the parent's depth, and use that to > resolve the conflict. If both of those are the same, continue > going up until the conflict is resolved. > > --- Vishal Kapur <[EMAIL PROTECTED]> wrote: > > > It looks like you spent some time on this response, I really > > appreciate that. As I mentioned in my first mail, depth, > _visible and > > _alpha are the properties I'm checking right now to resolve > conflicts. > > So my code looks very similar to your code below. > > This works > > sometimes, but I've run into cases where there are 2 movieclips for > > which hitTest() is true, _visible is true, _alpha is 100, and the > > depths are identical. One of the movieclips is obscured behind the > > other; there must be some way to distinguish them. > > Are there any > > other properties on movieclips (maybe hidden ones) that might be of > > use? The Flash runtime must be doing this internally for > onRollOver > > event firing; anyone know how this works? > > > > Thanks, > > Vishal > > > > > > > > On 2/7/07, Karina Steffens <[EMAIL PROTECTED]> > > wrote: > > > Ok, I see your problem, so lets think what else > > you can do with the hitTest > > > approach... > > > First of all, you can set the shape flag to true, > > so that the hit test will > > > only return true if there's something there (as > > opposed to the entire > > > bounding rect). > > > Then you can test for _alpha (you might want to > > test for _visible also), > > > thus eliminating invisible buttons, such as your > > big rectangle that obscures > > > the rest. > > > > > > Finally, checking for different depths - I > > recently discovered that if you > > > loop through a clip, it starts at the highest > > depth, even on the same layer: > > > for (var i in _root) { > > > trace(i + " " +_root[i].getDepth()); > > > } > > > > > > $version > > > clip3 -16379 > > > clip2 -16381 > > > clip1 -16383 > > > > > > So now you know which one has the highest depth: > > clip3, which also comes > > > first in the loop. > > > At this point, you can break the loop. If you need > > to go deeper, you can > > > then recurse within that clip, and see if it has > > any child mcs, which one of > > > those scores the highest hitTest and if that one > > has any children - etc. > > > > > > Here's some quick&dirty code: > > > > > > for (var i in _root) { > > > trace(i + " " +_root[i].getDepth()); > > > } > > > > > > _root.onEnterFrame = function() { > > > for (var i in this) { > > > var clip = this[i]; > > > if (!(clip instanceof MovieClip)) > > { > > > continue; > > > } > > > if (clip._alpha == 0 || > > clip._visible == 0) { > > > continue; > > > } > > > if (clip.hitTest(_root._xmouse, > > _root._ymouse, true)) { > > > trace(clip); > > > break; > > > } > > > } > > > }; > > > > > > On the timeline, I placed three circular clips > > overlapping eachother, so > > > that clip1 is at the lowest depth and clip3 at the > > highest. I made clip3 > > > invisible by setting it's alpha to 0. > > > > > > After moving my mouse over the clips, starting > > from the third, the trace > > > result was: > > > > > > $version > > > clip3 -16379 > > > clip2 -16381 > > > clip1 -16383 > > > _level0.clip2 > > > _level0.clip2 > > > _level0.clip2 > > > _level0.clip2 > > > _level0.clip2 > > > _level0.clip2 > > > _level0.clip2 > > > _level0.clip1 > > > _level0.clip1 > > > _level0.clip1 > > > > > > Each time the trace picked out the highest visible > > part of a clip, thus > > > resolving any conflicts. > > > > > > Hope this helps to point you in the right > > direction. > > > Karina > > > > > > > > > > -----Original Message----- > > > > From: Vishal Kapur [mailto:[EMAIL PROTECTED] > > > > Sent: 07 February 2007 20:29 > > > > To: Flashcoders mailing list > > > > Subject: Re: [Flashcoders] determining which > > object is > > > > displayed at agivenpoint > > > > > > > > To respond to the recent activity on this > > thread: > > > > Erik, the core functionality that I need really > > does need to > > > > be comprehensive and fairly generic: so, given > > any 3rd party > > > > swf which I don't have a priori knowledge of, > > determine which > > > > object is currently underneath the mouse. It > > needs to work > > > > for any movieclip or TextField object. It's > > proprietary so I > > > > can't really disclose why I need it. > > > > You mention that implementing this would be > > process > > > > intensive: this is ok to start. The way I would > > like to > > > > tackle this problem is to get it working > > functionally, and > > > > worry about performance later. > > > > > > > > Karina, Jason, the approaches you are suggesting > > of looping > > > > through all the movieclips and calling hitTest() > > on each one > > > > is exactly what my first approach was (see my > > first email in > > > > this thread). The problem is that very often > > multiple > > > > movieclips will return hitTest()==true for a > > given mouse > > > > position (clips at different depths, clips > > obscuring others, > > > > etc). That's what I meant by "2 conflicting > > objects" in my > > > > first mail. I'm trying to find an algorithm to > > resolve conflicts. > > > > > > > > There is another approach which Erik mentioned, > > which is to > > > > define/override the onRollOver callback for > > every object that > > > > I care about, and set some variable that keeps > > track of the > > > > last object that invoked onRollOver. I have > > tried this > > > > before, and I ditched it because I couldn't find > > a way to get > > > > TextField objects to invoke an onRollOver > > callback (or to > > > > otherwise respond to a 'roll over' event). > > > > Any ideas on this? > > > > > > > > Thanks, > > > > Vishal > > > > > > > > > > > > > > > > On 2/7/07, Jason Boyd <[EMAIL PROTECTED]> wrote: > > > > > I've been following this thread and am just > > curious -- > > > > everyone seems > > > > > to be assuming that looping through all clips > > and doing > > > > hitTest() is > > > > > inefficient, but presumably this is exactly > > what the Flash > > > > player is > > > === message truncated === > > > > > ______________________________________________________________ > ______________________ > Never Miss an Email > Stay connected with Yahoo! Mail on your mobile. Get started! > http://mobile.yahoo.com/services?promote=mail > _______________________________________________ > [email protected] > To change your subscription options or search the archive: > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > > Brought to you by Fig Leaf Software > Premier Authorized Adobe Consulting and Training > http://www.figleaf.com > http://training.figleaf.com > _______________________________________________ [email protected] To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com

