This is a good question, Newbie, and one that calls for experimentation.
"is within" is an operator, and pertains to a point in relation to a rect
"within" is a function, and pertains to a point in relation to an object. That said, it is the rect of the object that ultimately matters, and so you might consider them very similar, likely calling the same internal code.
"intersect" pertains to object rects as a whole, where one portion of a rect may overlie any portion of another. It can be viewed as "if even one point of one object is within the rect of another object".
Craig Newman
trash bin like feature
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Re: trash bin like feature
It doesn't matter really, the main thing is to avoid repeat loops in this kind of situation. Here is how I would do it:Newbie4 wrote:Does it matter if you use the "intersect" function, "is within" or the "within" function for testing if the object is in the trashcan?
Decide on a way to determine if an object is draggable. It can be a naming convention, a custom property, using a particular button type, or anything else. Put generic mouseDown and mouseUp handlers in the card. The handlers check to see if the object is draggable and handle the action if they are.
This is the cleanest way to do it because there are no repeat loops. Rule of thumb is to always use engine messages whenever possible. Here's a generic skeleton. These handlers assume that every draggable object is a button whose name begins with "drag-", but you can use any kind of test to see if the object is something that can be moved.
Code: Select all
on mouseDown
if the short name of the target begins with "drag-" then
grab the target
end if
end mouseDown
on mouseUp
if the short name of the target begins with "drag-" and \
the mouseloc is within the rect of btn "trash" then
-- do trash things
end if
end mouseUp
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com