Hi Roland,
You can put this in a movie script:
on getScriptInstanceCount whichScript
tempList = []
repeat with i = 1 to the lastChannel
if sprite(i).member.number > 0 then
if sprite(i).scriptList.count > 0 then
repeat with k = 1 to sprite(i).scriptList.count
if sprite(i).scriptList[k][1].name = whichScript then
tempList.add(i)
end if
end repeat
end if
end if
end repeat
return tempList.count
end
In the message window enter:
put getScriptInstanceCount("name of behaviour")
It will return the number of sprites to which the behaviour is attached. The function
above:
- steps through each channel in the score
- checks if a sprite is present
- checks to see if any behavior is attached to the sprite
- checks to see how many behaviors are attached
- checks if any of these behaviors match the name of the one you passed as whichScript
- adds the sprite number to a list
- the last line returns the count of the list i.e. the number of sprites the behavior
is attached to
You can return the complete list of sprites the behavior is attached to by removing
the '.count' property from the return line.
Hope this helps,
Erik
------------------------------
-- Erik Sandbergen
-- Integration New Media, Inc.
-- Montr�al, Canada
-- www.IntegrationNewMedia.com
------------------------------
> -----Original Message-----
> From: Roland [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, November 28, 2002 3:25 PM
> To: [EMAIL PROTECTED]
> Subject: <lingo-l> behaviours
>
>
> Hello all
>
> I have attached a behavior on a few sprites. How can I find
> out (number) on
> how many sprites the behavior has been attached to in order
> to place this
> number in a variable.
>
> Thanks for your replay
>
> Roland
>
> [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!]
>
[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!]