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
> > 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 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.
> > >
> > >
> > >
> > > _______________________________________________
> > > 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
>
_______________________________________________
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

Reply via email to