4 Replies Latest reply on Mar 5, 2007 1:50 PM by Newsgroup_User

    Determining when handlers receive a message

    Level 7
      The scripting reference states the text as below the line;

      how does this fit in with the order for mouseUp message processing:

      sprite - cast member - frame script - movie script


      -----------------------------------------------------------

      Determining when handlers receive a message

      After sending a message to scripts, Director checks for handlers in a
      definite order.

      1. Director first checks whether a handler exists in the object from
      which the message was sent. If a handler is found, the message is
      intercepted, and the script in the handler runs.
      2. If no handler is found, Director then checks cast member, in
      ascending order, for any associated movie scripts that might contain a
      handler for the message. If a handler is found, the message is
      intercepted, and the script in the handler runs.
      3. If no handler is found, Director then checks whether a frame
      script contains a handler for the message. If a handler is found, the
      message is intercepted, and the script in the handler runs.
      4. If no handler is found, Director then checks sprites, in
      ascending order, for any scripts associated with the sprites that might
      contain a handler for the message. If a handler is found, the message is
      intercepted, and the script in the handler runs.
        • 1. Re: Determining when handlers receive a message
          Level 7
          > how does this fit in with the order for mouseUp message processing:
          >
          > sprite - cast member - frame script - movie script

          Exactly as stated - if there is a behavior script attached to the sprite
          which contains an 'on mouseUp' handler then the event is intercepted at
          this point and doesn't propagate any further (usually).

          Otherwise, if there is a cast member script associated with the current
          sprite's member and /this/ script contains an 'on mouseUp' handler then...

          Otherwise if there is a script in the frameScript channel and it
          contains and 'on mouseUp' handler...

          Otherwise if there exists a movie script containing an 'on mouseUp'
          handler then...
          • 2. Re: Determining when handlers receive a message
            Level 7
            mm, I seem to have a few blind spots.





            1. Director first checks whether a handler exists in the object from
            which the message was sent.


            *1* Does this mean when for example some 'internal system object' sends
            some event, and I had an handler added to that object, the message is
            intercepted right at the source?



            2. ... Director then checks cast member, in ascending order, for any
            associated movie scripts that might contain a handler for the message.


            This *2* I do interpret: Director searches the movie scripts in the
            cast. But in this scenario sprite behaviours haven't been searched yet...


            3. ... Director then checks whether a frame script contains a
            handler for the message.



            *3* is clear to me; frame scripts are searched after movie scripts


            4. ... Director then checks sprites, in ascending order, for any
            scripts associated with the sprites that might contain a handler for the
            message.

            *4*

            Now sprites are searched last, instead of first. ;-(




            Sean Wilson wrote:
            >> how does this fit in with the order for mouseUp message processing:
            >>
            >> sprite - cast member - frame script - movie script
            >
            > Exactly as stated - if there is a behavior script attached to the sprite
            > which contains an 'on mouseUp' handler then the event is intercepted at
            > this point and doesn't propagate any further (usually).
            >
            > Otherwise, if there is a cast member script associated with the current
            > sprite's member and /this/ script contains an 'on mouseUp' handler then...
            >
            > Otherwise if there is a script in the frameScript channel and it
            > contains and 'on mouseUp' handler...
            >
            > Otherwise if there exists a movie script containing an 'on mouseUp'
            > handler then...
            • 3. Re: Determining when handlers receive a message
              Level 7
              > 1. Director first checks whether a handler exists in the object from
              > which the message was sent.
              >
              >
              > *1* Does this mean when for example some 'internal system object' sends
              > some event, and I had an handler added to that object, the message is
              > intercepted right at the source?

              It depends on your perceptions. When the left mouse button is released,
              the system generates a #mouseUp event. If the sprite that was under the
              mouse when the button was released has a behavior attached, AND if this
              behavior implements the 'on mouseUp' handler, then...

              > 2. ... Director then checks cast member, in ascending order, for any
              > associated movie scripts that might contain a handler for the message.
              >
              >
              > This *2* I do interpret: Director searches the movie scripts in the
              > cast. But in this scenario sprite behaviours haven't been searched yet...

              This refers to cast members scripts - scripts attached directly to
              members in the cast library. They aren't behaviors (score) scripts, nor
              movie scripts nor parent scripts. They are an outdated legacy which IMO
              should never be used. Feel free to ignore this option :-)
              If you wish to try creating one, select a cast member in a cast window
              (anything other than a script will do) and click the script icon next to
              the blue "Get Info" button towards the top-right of the cast window. Or
              hit Ctrl + '

              > 3. ... Director then checks whether a frame script contains a handler
              > for the message.
              >
              >
              >
              > *3* is clear to me; frame scripts are searched after movie scripts

              Rather, after cast member scripts.

              > 4. ... Director then checks sprites, in ascending order, for any
              > scripts associated with the sprites that might contain a handler for the
              > message.
              >
              > *4*
              >
              > Now sprites are searched last, instead of first. ;-(

              Sorry, I missed this first time through. It is incorrect: #movie scripts
              are searched last.
              • 4. Re: Determining when handlers receive a message
                Level 7
                Also, some events (keyUp/Down and mouseUp/Down) can be caught before
                they are sent to behaviors by using 'the keyDownScript' etc. Check the
                DOUG Lingo database for more details:
                < http://director-online.com/lingo.php?id=606>