The problem is that you can have the same member in one or more channels. For example, you could have the same bitmap in channels 3 and 10. Here's a routine I've been using for years (notice the "set" statement and pre-dot syntax). It finds the first occurance starting at channel 0

on FindSpriteWithName theName, fNotFoundReturnZero
set nChannels = the lastChannel
repeat with ch = 1 to nChannels
if the type of the member of sprite ch <> #empty then if word 1 of the name of the member of sprite ch = theName then -- You talking to me??
return ch
end if
end if
end repeat
if fNotFoundReturnZero then
return 0
else
alert("Could not find a sprite with the name:" && theName)
DebuggerBreak()
end if
end


If you want to allow for multiple copies of the same member, change the above code to build up a list of channels and return it. If the member is not found in any channel, it could return the empty list [].

Irv

At 3:06 PM -0700 3/11/03, Ron Woodland wrote:
A recent discussion thread discussed how to find the name of a cast member attached to a sprite. That's pretty straightforward and answered well by several list members.

Here's a challenge that has puzzled me for a long time. I usually take a coding shortcut because of time, but is there a way to find the sprite if the member number or name is known?

(x = the spriteNum of member "junk")

At first glance, this expression seems it would work. Even a rudimentary understanding of the concept of object properties shows this is a ludicrous expression. A cast member can't possibly have this property. However, it seems that there should be way to identify which sprite is using a known cast member.

-------------------------------------------------
Ronald Woodland -- St. George, Utah  84770
-------------------------------------------------
"I long to accomplish a great and noble task, but
it is my chief duty to accomplish small tasks as
if they were great and noble."  -- Helen Keller

[To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/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!]


--

Lingo / Director / Shockwave development for all occasions. (Home-made Lingo cooked up fresh every day just for you.)
[To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/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!]

Reply via email to