>If the mouse isn't to the right of the screen Kerry's routine would be
>quite a bit faster. On average his routine should come out a tiny bit
>faster than mine.
A little different test shows this more clearly. I left Colin's test as is,
except I reordered my nested if series to:
on mt2
if the mouseV > 370 then
if the mouseH > 385 then
if the mouseH < 475 then
if the mouseV < 393 then
Most of the time, the mouse should be outside of the rectangle. This
accounts for that--my previous post didn't.
On my machine, the empty handler took 4 milliseconds; the all-in-one took
44 milliseconds; the nested if's varied from 16 to 44; and the inside()
check took 29.
I ran 250 iterations of the frame script, and the average time for the
nested if approach was 21 milliseconds, or roughly 40% faster than the next
fastest approach.
Of course, as Colin pointed out, in this case, a few milliseconds doesn't
make that much difference. This particular one is more theory than
practice, but it's something worth knowing :-)
In Gopinath's case, he wants to check the coordinates on mouseUp, and he
was talking about a parent script. If I understand him right, I don't think
I would use any of these approaches--he would potentially have numerous
objects checking the mouseUp event, and it could be a nightmare to debug.
In his case, I think it's better to attach a mouseUp script to a
transparent sprite. That can all be done in an OOP framework, and would be
less prone to bugs.
Cordially,
Kerry Thompson
Learning Network
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/lingo-l.cgi To post messages to the list,
email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo. Thanks!]