Identifying objects by their tooltips

Shari shari at gypsyware.com
Mon Nov 21 08:30:42 CST 2005


>why don't you use custom properties instead ?
>
>JB

  I second that.  In the game Blackjack Gold I have many objects with 
the same properties.  If it's a chip, then I've set the whatEver of 
the object to "chip".

So in a handler:

if the whatEver of btn theBtn is "chip" then
    doTheThing
end if

If all of the objects already exist (like mine did), use a handler to 
set the properties.  (Using "if" prevents an error if there's any 
chance of a missing number, if the numbers are not 100% consecutive.)

put 1 into startNumber
repeat
   if there is a btn ("chip" & startNumber) then
      set the whatEver of btn ("chip" & startNumber) to "chip"
   else exit repeat
add 1 to startNumber
end repeat

repeat with x = 1 to someNumber
   if there is a btn ("chip" & x) then
      set the whatEver of btn ("chip" & x) to "chip"
   end if
end repeat

repeat with x = 1 to the number of btns of this card
   if there is a btn ("chip" & x) then
      set the whatEver of btn ("chip" & x) to "chip"
   end if
end if

You can also use the id numbers if they start and end with no other 
objects in the middle.

You could also trap for btns with a specific icon, or images of a 
specific size if there's no chance other images have that size, using 
the width and height.  Or several parameters if needed, such as the 
backColor, width, height, visible, etc.  Whatever makes all the 
objects the same, but different than another group of objects.

Shari
-- 
Mac and Windows shareware games
http://www.gypsyware.com


More information about the metacard mailing list