2 Replies Latest reply on May 26, 2008 2:20 PM by Newsgroup_User

    Handler Help

    Rurikar
      Hi I'm trying to figure out if it's possible to call from one script to the other. So say I have two different sprites with Behaviors on them, I would wanna do something like this:
        • 1. Re: Handler Help
          Level 7
          You can do that in a number of ways. If you know the sprite name or
          number that you are calling, and it is 100% guaranteed to exist what it
          is called, you can use syntax like this:

          sprite(2).customHandler()

          or

          sendSprite(2,#customHandler)

          The problem here is that if for some reason, the command is called when
          sprite(2) is no longer on the stage, or a sprite in channel 2 does not
          have the customHandler() method, then Director will crash with an error.

          You can use sendAllSprites() to circumvent that.

          sendAllSprites(#customHandler)

          That will send the customHandler() message to ALL sprites. If any of
          them have a customHandler() method, then they will run it. So it may
          happen multiple times if multiple sprites have that method.
          • 2. Handler Help
            multiduck
            Edit, already answered, disregard this post. :)