7 Replies Latest reply on Oct 3, 2006 10:58 AM by Newsgroup_User


    pemik Level 1
      beginSprite is supposed to be sent when the playhead enters a frame with a sprite that hasn't been encountered before.

      How come then that you can handle rollovers using a beginSprite handler to change the cursor property of a sprite? The playhead travels most of the way across the sprite before a 'hold on frame' script stops it - and the beginSprite appears to be triggered only with the mouseEnter, the endSprite with the mouseLeave. How come, if the message is sent just once for a given sprite, that this works repeatedly during the hold on frame?

      Is the message only sent when a non-frame event first occurs to it (rather than when the playhead enters it)?
        • 1. Re: beginSprite
          duckets Level 1
          no, it's when the playhead enters a frame with that sprite, as you describe in your first line.

          If you want to check, add this line to your beginsprite handler:

          on beginsprite me
          put me&" beginsprite!"

          The cursor property however, is a little unusual in that it is more like a property of the sprite channel rather than any particular sprite. So when you set the cursor of sprite 3, it will persist from then on, at any point in the score, and for whatever shape and type of cast member happens to be in sprite channel 3. For this reason, if you set the cursor of a sprite in your beginsprite handler, it's a good idea to set it back to zero in an endsprite handler in the same behaviour.

          hope this helps!

          - Ben
          • 2. Re: beginSprite
            Level 7
            If what you are doing is like this:

            on beginSprite me

            then, what Director is actually seeing is that you are setting it up so
            that the cursor changes whenever the mouse is over that sprite. You
            have set the sprite to have a cursor property that equals 280. It is
            not saying that the cursor will change on beginSprite, only that the
            sprite now knows it's cursor property is set to 280.

            When the cursor property is set that way, it will work much like it
            would if you added individual handlers for on mouseEnter, on mouseLeave,
            • 3. Re: beginSprite
              pemik Level 1
              thanks Ben. I understand that the message is sent then, what I don't understand is why the rollover works!

              Within the beginSprite handler I set the cursor of sprite the spriteNum of me = 290 (and put beginSprite) - the beginSprite is put immediately the playhead encounters the sprite (as expected), but the cursor doesn't change until the mouseEnter event occurs.
              • 4. Re: beginSprite
                Level 7
                You are misunderstanding the use of the cursor property of a sprite.
                Setting it to 290 will make it respond to rollovers with the cursor
                #290. If you want the cursor to change as soon as the sprite appears on
                stage for some reason, then you would use

                on beginSprite me
                cursor 290

                That way it changes the cursor and the state of the cursor has nothing
                to do with the mouse or where it is in relation to this sprite or any other.
                • 5. Re: beginSprite
                  pemik Level 1
                  Thanks Mike, you're right - it's the cursor property of the sprite I've misunderstood. I've just looked it up, it determines the cursor used when the pointer is over a sprite. Presumably setting it in mouseLeave will store the value it should return to when the ponter leaves?

                  I normally use the cursor() method in a mouseEnter script...not sure if there's any particular advantage to using the cursor property on beginSprite? Seems less intuitive.
                  • 6. Re: beginSprite
                    duckets Level 1
                    the cursor property is quite unusual in that it kind of uses its own 'rollover' code. What you're doing when you set the cursor property of a sprite is you are specifying what cursor should display when the mouse is over the sprite. It will change back when the mouse leaves the sprite. No mouseenter or mouseleave handlers necessary.
                    • 7. Re: beginSprite
                      Level 7
                      Neither method is better than the other, but they have different uses.
                      If you set the cursor property of the sprite, then you basically get all
                      of the cursor interactions with that sprite done in 1 line of code.
                      That is better from a typing standpoint (less to type), and it prevents
                      problems where you may have put in the mouseEnter code but forgot the

                      this command:

                      on beginSprite me

                      is exactly the same as the following set of commands:

                      on mouseEnter me
                      cursor 290

                      on mouseLeave me
                      cursor 0

                      on endSprite me
                      cursor 0

                      It is less good sometimes in that it is less configurable. If you are
                      entering all the cursors in manually, you can have different cursors for
                      mouseDown or mouseUp or any other events you want to use. That isn't
                      needed too often, so it is generally easiest to just go with the 1 liner.