RE: [Flashcoders] determining which object is displayed at agivenpoint

2007-02-09 Thread Erik Bianchi
I think he is referring to the following class from another thread. One
problem pertaining to your issue is that it doesn't take into consideration
depth. It is still more process intensive then just firing a callback on
rollOver but could be useful for you and give you some ideas: 

class com.domain.RollWhileWithin extends MovieClip {
public var rolled:Boolean;

function RollWhileWithin () 
{
rolled = false;
}
public function doRollOver():Void 
{
if (!rolled) {
rolled = true;
gotoAndStop("over");
}
}
public function doRollOut():Void 
{
if (rolled) {
rolled = false;
gotoAndStop("up");
}
}
}




One level above it, you can manage as many clips as there are.

var checkMouseInterval:Number;
clearInterval(checkMouseInterval);
checkMouseInterval = setInterval(this, "checkMouse", 100); private function
checkMouse():Void {
var i:Number = 5;
while (i--) {
var clip:MovieClip = this["MC_RollClip" + i];
if (_xmouse > clip._x && _xmouse < clip._x + clip._width &&
_ymouse > clip._y && _ymouse < clip._y + clip._height) {
clip.doRollOver();
} else {
clip.doRollOut();
}
}
}

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Vishal Kapur
Sent: Thursday, February 08, 2007 11:19 PM
To: Flashcoders mailing list
Subject: Re: [Flashcoders] determining which object is displayed at
agivenpoint

Ok.  This is what I was missing.  Thanks to Karina and Erik for
pointing out that you need to compare the entire parent chain of two
objects to figure out which one is being rendered above the other.

The only thing to add is that in addition to checking depths, the
_visible property needs to be checked for the parent chain for each
object (so if _visible is false anywhere in the parent chain, I
consider that object to be invisible).  This works in all cases except
for some TextFields, where the bounding box of the textfield object is
bigger than the area actually occupied by the text.  This can be
solved with a custom hitTest() implementation that uses
Textfield.textWidth and .textHeight to get the bounding box of the
displayed text.  An interesting corollary is that this method would be
a way to implement onRollOver for TextFields (if that ever proves
useful to anyone).

Steven, I'm not familiar with the class you're referring to.  Could
you send the link to it?  I'm always looking to improve the simplicity
and efficiency of my code...

-- Vishal


On 2/8/07, Steven Sacks | BLITZ <[EMAIL PROTECTED]> wrote:
> I think the class I wrote works well enough, I actually pulled it out of
> an app I'm working on with complex rollovers like that.  Why not
> consider my way?  It's simple, easy and, most importantly, it works.  It
> hardly takes any processing power, too.
>
>
> ___
> Flashcoders@chattyfig.figleaf.com
> 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
>
___
Flashcoders@chattyfig.figleaf.com
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


___
Flashcoders@chattyfig.figleaf.com
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


RE: [Flashcoders] determining which object is displayed at agivenpoint

2007-02-09 Thread Steven Sacks | BLITZ
Oops.  I responded to the wrong thread, I'm sorry.  :(

That being said, perhaps rethinking your approach would help. There's a
tutorial on Kirupa about managing z-order stacking of movieclips which
might contribute to a solution.

http://www.kirupa.com/developer/actionscript/3dexplore.htm

___
Flashcoders@chattyfig.figleaf.com
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


Re: [Flashcoders] determining which object is displayed at agivenpoint

2007-02-08 Thread Vishal Kapur

Ok.  This is what I was missing.  Thanks to Karina and Erik for
pointing out that you need to compare the entire parent chain of two
objects to figure out which one is being rendered above the other.

The only thing to add is that in addition to checking depths, the
_visible property needs to be checked for the parent chain for each
object (so if _visible is false anywhere in the parent chain, I
consider that object to be invisible).  This works in all cases except
for some TextFields, where the bounding box of the textfield object is
bigger than the area actually occupied by the text.  This can be
solved with a custom hitTest() implementation that uses
Textfield.textWidth and .textHeight to get the bounding box of the
displayed text.  An interesting corollary is that this method would be
a way to implement onRollOver for TextFields (if that ever proves
useful to anyone).

Steven, I'm not familiar with the class you're referring to.  Could
you send the link to it?  I'm always looking to improve the simplicity
and efficiency of my code...

-- Vishal


On 2/8/07, Steven Sacks | BLITZ <[EMAIL PROTECTED]> wrote:

I think the class I wrote works well enough, I actually pulled it out of
an app I'm working on with complex rollovers like that.  Why not
consider my way?  It's simple, easy and, most importantly, it works.  It
hardly takes any processing power, too.


___
Flashcoders@chattyfig.figleaf.com
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


___
Flashcoders@chattyfig.figleaf.com
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


RE: [Flashcoders] determining which object is displayed at agivenpoint

2007-02-08 Thread Steven Sacks | BLITZ
I think the class I wrote works well enough, I actually pulled it out of
an app I'm working on with complex rollovers like that.  Why not
consider my way?  It's simple, easy and, most importantly, it works.  It
hardly takes any processing power, too.


___
Flashcoders@chattyfig.figleaf.com
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


RE: [Flashcoders] determining which object is displayed at agivenpoint

2007-02-08 Thread Erik Bianchi
For every mousemove or enterframe (however, you decide to check hittest) you
have to loop through and hittest every movieclip you want to check.

So say for example we are talking about just 10 movieclips checking using
enterframe at 30 frames per-second (assumming Flash Player is actually
running at 30fps) you're technically looping through 300 movieclips
persecond and running 300 hitTest persecond. That's a lot of processing for
just 10 movieclips. Which is why I suggest using some other method.

If you setup a test calculating FPS you'll see that hitTest / looping will
tax the processor much more then setting an onRollOver.

-erik

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Jason Boyd
Sent: Wednesday, February 07, 2007 11:43 AM
To: Flashcoders mailing list
Subject: Re: [Flashcoders] determining which object is displayed at
agivenpoint

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 doing with every
mouse move. Is there some good reason to assume the Flash player is doing
this internally much more efficiently than the function exposed through AS
as hitTest()? Without a priori knowledge, I'd recommend trying this, and if
it doesnt turn out to noticeably slow anything, you're done.



On 2/7/07, Karina Steffens <[EMAIL PROTECTED]> wrote:
>
> Hi Vishal,
>
> I apologise ahead if I'm being dense here, but nobody seems to have
> mentioned the obvious solution:
> Looping through the mcs in your third party flash movie and checking for
> hit-test with the mouse position.
>
> var hit_array:Array = [];
> for (var i:String in target_mc){
>   var mc:MovieClip = target_mc[i];
>   if (!mc instanceof MovieClip){
>   //not a movie clip - ignore
> continue;
>   }
>   //Check for hit test
>   if (target_mc[i].hitTest(_root._xmouse, _root._ymouse, true)
> hit_array.push(target_mc);
>   }
> }
>
> At the end of it you have an array of all the movie clips that "scored" a
> hit test.
>
> This code is just off the top of my head, an thoroughly untested. Also
> Depending on the structure of your flash movie, you will probably want to
> delve deeper and test for a hit within each movie clip that you encounter.
> It's also not very efficient, especially if you have to do recursion, so I
> wouldn't recommend doing it too often. (don't use onMouseMove but rather
> an
> enterFrame event, an interval or some kind of once-off event - depending
> on
> your application).
>
> Alternatively, if you already know which objects should be tested, you can
> do this more efficiently by hard-coding them manually into an array and
> looping within the array to check for a hit test. Not pretty, but should
> work.
>
> And finally, something that occurred to me while writing this post, you
> could try temporarily switching off the _visible property of the
> overlapping
> clip just before checking for _droptarget - and then switching it on
> again.
> This might be the least processor-intensive way of doing this.
>
> Cheers,
> Karina
>
>
>
>
>
> > -Original Message-
> > From: Vishal Kapur [mailto:[EMAIL PROTECTED]
> > Sent: 07 February 2007 01:26
> > To: Flashcoders mailing list
> > Subject: Re: [Flashcoders] determining which object is
> > displayed at agivenpoint
> >
> > Ok, got it.  Thanks for the suggestion.  I tried this but it
> > doesn't work with the third-party flash movie I am looking
> > at.  They have an movie clip with _alpha set to 0 that covers
> > the stage at a depth higher than all other visible elements.
> > As a result _droptarget is always set to that object.  What I
> > need is something that takes into account visibility.
> >
> > Any other thoughts on this?
> >
> > -- Vishal
> >
> >
> > On 2/6/07, Mike Mountain <[EMAIL PROTECTED]> wrote:
> > >  What he's saying is that _droptarget will tell you exactly
> > what is at
> > > the top under the users mouse - but in order to use it you
> > have to use
> > > startDrag to fool it in to working. Maybe you could drag an
> > invisible
> > > clip around or something.
> > >
> > > M
> > >
> > > > -Original Message-
> > > > From: [EMAIL PROTECTED]
> > > > [mailto:[EMAIL PROTECTED] On Behalf Of
> > > > Vishal Kapur
> > > > Sent: 06 February 2007 16:03
> > > > To: Flashcoders mailing list
> > > > Subject: Re: [Flashcoders] determining which object is

RE: [Flashcoders] determining which object is displayed at agivenpoint

2007-02-08 Thread Erik Bianchi
If performance isn't an issue, you can use getDepth to figure out the top
most mc / textfield and then just act on it (place into a zorder array and
use depth for index). However, that is a more process intensive way of
emulating onRollOver. For textfield's you are correct. You can't catch
onRollOver unless it is wrapped by a movieclip; is that out of the question?



-erik

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Vishal Kapur
Sent: Wednesday, February 07, 2007 12:29 PM
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 doing with every
> mouse move. Is there some good reason to assume the Flash player is doing
> this internally much more efficiently than the function exposed through AS
> as hitTest()? Without a priori knowledge, I'd recommend trying this, and
if
> it doesnt turn out to noticeably slow anything, you're done.
>
>
>
> On 2/7/07, Karina Steffens <[EMAIL PROTECTED]> wrote:
> >
> > Hi Vishal,
> >
> > I apologise ahead if I'm being dense here, but nobody seems to have
> > mentioned the obvious solution:
> > Looping through the mcs in your third party flash movie and checking for
> > hit-test with the mouse position.
> >
> > var hit_array:Array = [];
> > for (var i:String in target_mc){
> >   var mc:MovieClip = target_mc[i];
> >   if (!mc instanceof MovieClip){
> >   //not a movie clip - ignore
> > continue;
> >   }
> >   //Check for hit test
> >   if (target_mc[i].hitTest(_root._xmouse, _root._ymouse, true)
> > hit_array.push(target_mc);
> >   }
> > }
> >
> > At the end of it you have an array of all the movie clips that "scored"
a
> > hit test.
> >
> > This code is just off the top of my head, an thoroughly untested. Also
> > Depending on the structure of your flash movie, you will probably want
to
> > delve deeper and test for a hit within each movie clip that you
encounter.
> > It's also not very efficient, especially if you have to do recursion, so
I
> > wouldn't recommend doing it too often. (don't use onMouseMove but rather
> > an
> > enterFrame event, an interval or some kind of once-off event - depending
> > on
> > your application).
> >
> > Alternatively, if you already know which objects should be tested, you
can
> > do this more efficiently by hard-coding them manually into an array and
> > looping within the array to check for a hit test. Not pretty, but should
> > work.
> >
> > And finally, something that occurred to me while writing this post, you
> > could try temporarily switching off the _visible property of the
> > overlapping
> > clip just before checking for _droptarget - and then switching it on
> > again.
> > This might be the least processor-intensive way of doing this.
> >
> > Cheers

RE: [Flashcoders] determining which object is displayed at agivenpoint

2007-02-08 Thread Erik Bianchi
Depths cant be identical in the same timeline so what you'll have to do is
check the depth of the _parent clip in case of equal depth

-erik

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Vishal Kapur
Sent: Wednesday, February 07, 2007 11:05 PM
To: Flashcoders mailing list
Subject: Re: [Flashcoders] determining which object is displayed at
agivenpoint

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

RE: [Flashcoders] determining which object is displayed at agivenpoint

2007-02-08 Thread Karina Steffens
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
> > &g

Re: [Flashcoders] determining which object is displayed at agivenpoint

2007-02-07 Thread Joshua Sera
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 

Re: [Flashcoders] determining which object is displayed at agivenpoint

2007-02-07 Thread Vishal Kapur

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?
>
> 

RE: [Flashcoders] determining which object is displayed at agivenpoint

2007-02-07 Thread Karina Steffens
Jason -

This is a valid point, but even if flash is doing it with every mouse move,
it's probably not a good idea to make it do it all over again each time...
But I'm not sure what's more efficient - mouseMove, enterFrame or mouseOver?


> -Original Message-
> From: Jason Boyd [mailto:[EMAIL PROTECTED] 
> Sent: 07 February 2007 19:43
> To: Flashcoders mailing list
> Subject: Re: [Flashcoders] determining which object is 
> displayed at agivenpoint
> 
> 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 doing with every mouse move. 
> Is there some good reason to assume the Flash player is doing 
> this internally much more efficiently than the function 
> exposed through AS as hitTest()? Without a priori knowledge, 
> I'd recommend trying this, and if it doesnt turn out to 
> noticeably slow anything, you're done.
> 
> 
> 
> On 2/7/07, Karina Steffens <[EMAIL PROTECTED]> wrote:
> >
> > Hi Vishal,
> >
> > I apologise ahead if I'm being dense here, but nobody seems to have 
> > mentioned the obvious solution:
> > Looping through the mcs in your third party flash movie and 
> checking 
> > for hit-test with the mouse position.
> >
> > var hit_array:Array = [];
> > for (var i:String in target_mc){
> >   var mc:MovieClip = target_mc[i];
> >   if (!mc instanceof MovieClip){
> >   //not a movie clip - ignore
> > continue;
> >   }
> >   //Check for hit test
> >   if (target_mc[i].hitTest(_root._xmouse, _root._ymouse, true)
> > hit_array.push(target_mc);
> >   }
> > }
> >
> > At the end of it you have an array of all the movie clips that 
> > "scored" a hit test.
> >
> > This code is just off the top of my head, an thoroughly 
> untested. Also 
> > Depending on the structure of your flash movie, you will 
> probably want 
> > to delve deeper and test for a hit within each movie clip 
> that you encounter.
> > It's also not very efficient, especially if you have to do 
> recursion, 
> > so I wouldn't recommend doing it too often. (don't use 
> onMouseMove but 
> > rather an enterFrame event, an interval or some kind of 
> once-off event 
> > - depending on your application).
> >
> > Alternatively, if you already know which objects should be 
> tested, you 
> > can do this more efficiently by hard-coding them manually into an 
> > array and looping within the array to check for a hit test. Not 
> > pretty, but should work.
> >
> > And finally, something that occurred to me while writing this post, 
> > you could try temporarily switching off the _visible 
> property of the 
> > overlapping clip just before checking for _droptarget - and then 
> > switching it on again.
> > This might be the least processor-intensive way of doing this.
> >
> > Cheers,
> > Karina
> >
> >
> >
> >
> >
> > > -Original Message-
> > > From: Vishal Kapur [mailto:[EMAIL PROTECTED]
> > > Sent: 07 February 2007 01:26
> > > To: Flashcoders mailing list
> > > Subject: Re: [Flashcoders] determining which object is 
> displayed at 
> > > agivenpoint
> > >
> > > Ok, got it.  Thanks for the suggestion.  I tried this but 
> it doesn't 
> > > work with the third-party flash movie I am looking at.  
> They have an 
> > > movie clip with _alpha set to 0 that covers the stage at a depth 
> > > higher than all other visible elements.
> > > As a result _droptarget is always set to that object.  
> What I need 
> > > is something that takes into account visibility.
> > >
> > > Any other thoughts on this?
> > >
> > > -- Vishal
> > >
> > >
> > > On 2/6/07, Mike Mountain <[EMAIL PROTECTED]> wrote:
> > > >  What he's saying is that _droptarget will tell you exactly
> > > what is at
> > > > the top under the users mouse - but in order to use it you
> > > have to use
> > > > startDrag to fool it in to working. Maybe you could drag an
> > > invisible
> > > > clip around or something.
> > > >
> > > > M
> > > >
> > > > > -Original Message-
> > > > > From: [EMAIL PROTECTED]
> > > > > [mailto:[EMAIL PROTECTED] On 
> Behalf Of 
> > > > > Vishal Kap

RE: [Flashcoders] determining which object is displayed at agivenpoint

2007-02-07 Thread Karina Steffens
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 
> > doing with every mouse move. Is there some good reason to 
> assume the 
> > Flash player is doing this internally much more efficiently 
> than the 
> > function exposed through AS as hitTest()? Without a priori 
> knowledge, 
> > I'd recommend trying this, and if it doesnt turn out to 
> noticeably slow anything, you're done.
> >
> >

Re: [Flashcoders] determining which object is displayed at agivenpoint

2007-02-07 Thread Vishal Kapur

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 doing with every
mouse move. Is there some good reason to assume the Flash player is doing
this internally much more efficiently than the function exposed through AS
as hitTest()? Without a priori knowledge, I'd recommend trying this, and if
it doesnt turn out to noticeably slow anything, you're done.



On 2/7/07, Karina Steffens <[EMAIL PROTECTED]> wrote:
>
> Hi Vishal,
>
> I apologise ahead if I'm being dense here, but nobody seems to have
> mentioned the obvious solution:
> Looping through the mcs in your third party flash movie and checking for
> hit-test with the mouse position.
>
> var hit_array:Array = [];
> for (var i:String in target_mc){
>   var mc:MovieClip = target_mc[i];
>   if (!mc instanceof MovieClip){
>   //not a movie clip - ignore
> continue;
>   }
>   //Check for hit test
>   if (target_mc[i].hitTest(_root._xmouse, _root._ymouse, true)
> hit_array.push(target_mc);
>   }
> }
>
> At the end of it you have an array of all the movie clips that "scored" a
> hit test.
>
> This code is just off the top of my head, an thoroughly untested. Also
> Depending on the structure of your flash movie, you will probably want to
> delve deeper and test for a hit within each movie clip that you encounter.
> It's also not very efficient, especially if you have to do recursion, so I
> wouldn't recommend doing it too often. (don't use onMouseMove but rather
> an
> enterFrame event, an interval or some kind of once-off event - depending
> on
> your application).
>
> Alternatively, if you already know which objects should be tested, you can
> do this more efficiently by hard-coding them manually into an array and
> looping within the array to check for a hit test. Not pretty, but should
> work.
>
> And finally, something that occurred to me while writing this post, you
> could try temporarily switching off the _visible property of the
> overlapping
> clip just before checking for _droptarget - and then switching it on
> again.
> This might be the least processor-intensive way of doing this.
>
> Cheers,
> Karina
>
>
>
>
>
> > -Original Message-
> > From: Vishal Kapur [mailto:[EMAIL PROTECTED]
> > Sent: 07 February 2007 01:26
> > To: Flashcoders mailing list
> > Subject: Re: [Flashcoders] determining which object is
> > displayed at agivenpoint
> >
> > Ok, got it.  Thanks for the suggestion.  I tried this but it
> > doesn't work with the third-party flash movie I am looking
> > at.  They have an movie clip with _alpha set to 0 that covers
> > the stage at a depth higher than all other visible elements.
> > As a result _droptarget is always set to that object.  What I
> > need is something that takes into account visibility.
> >
> > Any other thoughts on this?
> >
> > -- Vishal
> >
> >
> > On 2/6/07, Mike Mountain <[EMAIL PROTECTED]> wrote:
> > >  What he&#

Re: [Flashcoders] determining which object is displayed at agivenpoint

2007-02-07 Thread Jason Boyd

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 doing with every
mouse move. Is there some good reason to assume the Flash player is doing
this internally much more efficiently than the function exposed through AS
as hitTest()? Without a priori knowledge, I'd recommend trying this, and if
it doesnt turn out to noticeably slow anything, you're done.



On 2/7/07, Karina Steffens <[EMAIL PROTECTED]> wrote:


Hi Vishal,

I apologise ahead if I'm being dense here, but nobody seems to have
mentioned the obvious solution:
Looping through the mcs in your third party flash movie and checking for
hit-test with the mouse position.

var hit_array:Array = [];
for (var i:String in target_mc){
  var mc:MovieClip = target_mc[i];
  if (!mc instanceof MovieClip){
  //not a movie clip - ignore
continue;
  }
  //Check for hit test
  if (target_mc[i].hitTest(_root._xmouse, _root._ymouse, true)
hit_array.push(target_mc);
  }
}

At the end of it you have an array of all the movie clips that "scored" a
hit test.

This code is just off the top of my head, an thoroughly untested. Also
Depending on the structure of your flash movie, you will probably want to
delve deeper and test for a hit within each movie clip that you encounter.
It's also not very efficient, especially if you have to do recursion, so I
wouldn't recommend doing it too often. (don't use onMouseMove but rather
an
enterFrame event, an interval or some kind of once-off event - depending
on
your application).

Alternatively, if you already know which objects should be tested, you can
do this more efficiently by hard-coding them manually into an array and
looping within the array to check for a hit test. Not pretty, but should
work.

And finally, something that occurred to me while writing this post, you
could try temporarily switching off the _visible property of the
overlapping
clip just before checking for _droptarget - and then switching it on
again.
This might be the least processor-intensive way of doing this.

Cheers,
Karina





> -Original Message-
> From: Vishal Kapur [mailto:[EMAIL PROTECTED]
> Sent: 07 February 2007 01:26
> To: Flashcoders mailing list
> Subject: Re: [Flashcoders] determining which object is
> displayed at agivenpoint
>
> Ok, got it.  Thanks for the suggestion.  I tried this but it
> doesn't work with the third-party flash movie I am looking
> at.  They have an movie clip with _alpha set to 0 that covers
> the stage at a depth higher than all other visible elements.
> As a result _droptarget is always set to that object.  What I
> need is something that takes into account visibility.
>
> Any other thoughts on this?
>
> -- Vishal
>
>
> On 2/6/07, Mike Mountain <[EMAIL PROTECTED]> wrote:
> >  What he's saying is that _droptarget will tell you exactly
> what is at
> > the top under the users mouse - but in order to use it you
> have to use
> > startDrag to fool it in to working. Maybe you could drag an
> invisible
> > clip around or something.
> >
> > M
> >
> > > -Original Message-
> > > From: [EMAIL PROTECTED]
> > > [mailto:[EMAIL PROTECTED] On Behalf Of
> > > Vishal Kapur
> > > Sent: 06 February 2007 16:03
> > > To: Flashcoders mailing list
> > > Subject: Re: [Flashcoders] determining which object is
> displayed at
> > > a givenpoint
> > >
> > > I don't understand what you're suggesting.  The user is
> not dragging
> > > the movieclip.
> > >
> > > The idea is to write a function with a signature like:
> > > function getObjectAtPoint(xmouse:Number, ymouse:Number):Object
> >
> >
> > ECM Systems Ltd, Ellifoot Park, Burstwick, East Yorkshire HU12 9DZ
> > Tel: 01964 672000
> > Fax: 01964 671102
> > Registered in England no. 01646471
> > The information contained within this email expresses the
> views of the sender and not necessarily those of the company.
> It is private and confidential and may be legally privileged.
> It is intended solely for those authorised to receive it. If
> you are not the intended recipient you are hereby notified
> that any disclosure, copying, distribution or action taken in
> reliance on its contents is strictly prohibited and may be
> unlawful. If you have received this email in error, please
> telephone us immediately on 01964 672000 or email a reply to
> highlight the error and then delete it from your system. This
> email may contain links to web-sites, the contents of which
> ECM Systems Ltd have no control over and can accept no
> 

RE: [Flashcoders] determining which object is displayed at agivenpoint

2007-02-07 Thread Karina Steffens
Hi Vishal,

I apologise ahead if I'm being dense here, but nobody seems to have
mentioned the obvious solution:
Looping through the mcs in your third party flash movie and checking for
hit-test with the mouse position.

var hit_array:Array = []; 
for (var i:String in target_mc){
  var mc:MovieClip = target_mc[i];
  if (!mc instanceof MovieClip){
  //not a movie clip - ignore
continue;
  }  
  //Check for hit test
  if (target_mc[i].hitTest(_root._xmouse, _root._ymouse, true)
hit_array.push(target_mc);
  }
}

 At the end of it you have an array of all the movie clips that "scored" a
hit test.

This code is just off the top of my head, an thoroughly untested. Also
Depending on the structure of your flash movie, you will probably want to
delve deeper and test for a hit within each movie clip that you encounter.
It's also not very efficient, especially if you have to do recursion, so I
wouldn't recommend doing it too often. (don't use onMouseMove but rather an
enterFrame event, an interval or some kind of once-off event - depending on
your application).

Alternatively, if you already know which objects should be tested, you can
do this more efficiently by hard-coding them manually into an array and
looping within the array to check for a hit test. Not pretty, but should
work.

And finally, something that occurred to me while writing this post, you
could try temporarily switching off the _visible property of the overlapping
clip just before checking for _droptarget - and then switching it on again.
This might be the least processor-intensive way of doing this.

Cheers,
Karina





> -Original Message-
> From: Vishal Kapur [mailto:[EMAIL PROTECTED] 
> Sent: 07 February 2007 01:26
> To: Flashcoders mailing list
> Subject: Re: [Flashcoders] determining which object is 
> displayed at agivenpoint
> 
> Ok, got it.  Thanks for the suggestion.  I tried this but it 
> doesn't work with the third-party flash movie I am looking 
> at.  They have an movie clip with _alpha set to 0 that covers 
> the stage at a depth higher than all other visible elements.  
> As a result _droptarget is always set to that object.  What I 
> need is something that takes into account visibility.
> 
> Any other thoughts on this?
> 
> -- Vishal
> 
> 
> On 2/6/07, Mike Mountain <[EMAIL PROTECTED]> wrote:
> >  What he's saying is that _droptarget will tell you exactly 
> what is at 
> > the top under the users mouse - but in order to use it you 
> have to use 
> > startDrag to fool it in to working. Maybe you could drag an 
> invisible 
> > clip around or something.
> >
> > M
> >
> > > -Original Message-
> > > From: [EMAIL PROTECTED]
> > > [mailto:[EMAIL PROTECTED] On Behalf Of 
> > > Vishal Kapur
> > > Sent: 06 February 2007 16:03
> > > To: Flashcoders mailing list
> > > Subject: Re: [Flashcoders] determining which object is 
> displayed at 
> > > a givenpoint
> > >
> > > I don't understand what you're suggesting.  The user is 
> not dragging 
> > > the movieclip.
> > >
> > > The idea is to write a function with a signature like:
> > > function getObjectAtPoint(xmouse:Number, ymouse:Number):Object
> >
> >
> > ECM Systems Ltd, Ellifoot Park, Burstwick, East Yorkshire HU12 9DZ
> > Tel: 01964 672000
> > Fax: 01964 671102
> > Registered in England no. 01646471
> > The information contained within this email expresses the 
> views of the sender and not necessarily those of the company. 
> It is private and confidential and may be legally privileged. 
> It is intended solely for those authorised to receive it. If 
> you are not the intended recipient you are hereby notified 
> that any disclosure, copying, distribution or action taken in 
> reliance on its contents is strictly prohibited and may be 
> unlawful. If you have received this email in error, please 
> telephone us immediately on 01964 672000 or email a reply to 
> highlight the error and then delete it from your system. This 
> email may contain links to web-sites, the contents of which 
> ECM Systems Ltd have no control over and can accept no 
> responsibility for. Any attachments have been virus-checked 
> before transmission; however, recipients are strongly advised 
> to carry out their own virus checking as ECM Systems Ltd do 
> not warrant that such attachments are virus-free. Please note 
> that this email has been created in the knowledge that 
> Internet email is not a secure communications medium. We 
> advise that you understand and observe this lack of security 
> when emailing us.
> >
> > ECM Systems Ltd, Ellifoot Park, Burstwick, East Yorkshire HU1

RE: [Flashcoders] determining which object is displayed at agivenpoint

2007-02-06 Thread Erik Bianchi
I'm not sure how your app is structured but if you can't put your movieclips
above this 3rd party movieclip you wont be able to use _droptarget (as
you've already discovered) unless you can set that interfering movieclips
visibility to false.

I'm not sure how / why you want to check what mc the mouse is over, but you
could also just manually set movieclips to set an "over" variable onRollOver
/ onRollOut or onPress.

The reason why I'm suggesting one of these methods is that all other options
will be much more complex, processor intensive and time consuming.
Unfortunately there is no getMovieClipAt(x,y) method.

Your best bet is to think about what core functionality you really need and
go with the cheapest solution. So if your goal isn't as broad as knowing
EVERY movieclips position / depth maybe you can put a few invisible
movieclips over the 3rd party clip that represents the position of the mcs
you really care about.

-erik



-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Vishal Kapur
Sent: Tuesday, February 06, 2007 5:26 PM
To: Flashcoders mailing list
Subject: Re: [Flashcoders] determining which object is displayed at
agivenpoint

Ok, got it.  Thanks for the suggestion.  I tried this but it doesn't
work with the third-party flash movie I am looking at.  They have an
movie clip with _alpha set to 0 that covers the stage at a depth
higher than all other visible elements.  As a result _droptarget is
always set to that object.  What I need is something that takes into
account visibility.

Any other thoughts on this?

-- Vishal


On 2/6/07, Mike Mountain <[EMAIL PROTECTED]> wrote:
>  What he's saying is that _droptarget will tell you exactly what is at
> the top under the users mouse - but in order to use it you have to use
> startDrag to fool it in to working. Maybe you could drag an invisible
> clip around or something.
>
> M
>
> > -Original Message-
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED] On Behalf
> > Of Vishal Kapur
> > Sent: 06 February 2007 16:03
> > To: Flashcoders mailing list
> > Subject: Re: [Flashcoders] determining which object is
> > displayed at a givenpoint
> >
> > I don't understand what you're suggesting.  The user is not
> > dragging the movieclip.
> >
> > The idea is to write a function with a signature like:
> > function getObjectAtPoint(xmouse:Number, ymouse:Number):Object
>
>
> ECM Systems Ltd, Ellifoot Park, Burstwick, East Yorkshire HU12 9DZ
> Tel: 01964 672000
> Fax: 01964 671102
> Registered in England no. 01646471
> The information contained within this email expresses the views of the
sender and not necessarily those of the company. It is private and
confidential and may be legally privileged. It is intended solely for those
authorised to receive it. If you are not the intended recipient you are
hereby notified that any disclosure, copying, distribution or action taken
in reliance on its contents is strictly prohibited and may be unlawful. If
you have received this email in error, please telephone us immediately on
01964 672000 or email a reply to highlight the error and then delete it from
your system. This email may contain links to web-sites, the contents of
which ECM Systems Ltd have no control over and can accept no responsibility
for. Any attachments have been virus-checked before transmission; however,
recipients are strongly advised to carry out their own virus checking as ECM
Systems Ltd do not warrant that such attachments are virus-free. Please note
that this email has been created in the knowledge that Internet email is not
a secure communications medium. We advise that you understand and observe
this lack of security when emailing us.
>
> ECM Systems Ltd, Ellifoot Park, Burstwick, East Yorkshire HU12 9DZ
>
> Tel: 01964 672000
> Fax: 01964 671102
>
> Registered in England no. 01646471
>
> The information contained within this email expresses the views of the
sender and not necessarily those of the company.
> It is private and confidential and may be legally privileged. It is
intended solely for those authorised to receive it. If you are
> not the intended recipient you are hereby notified that any disclosure,
copying, distribution or action taken in reliance on its
> contents is strictly prohibited and may be unlawful. If you have received
this email in error, please telephone us immediately
> on 01964 672000 or email a reply to highlight the error and then delete it
from your system. This email may contain links to
> web-sites, the contents of which ECM Systems Ltd have no control over and
can accept no responsibility for. Any
> attachments have been virus-checked before transmission; however,
recipients are strongly advised to carry out their own
> virus