This content has been marked as final. Show 7 replies
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!
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,
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.
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
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.
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.
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.
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
on beginSprite me
is exactly the same as the following set of commands:
on mouseEnter me
on mouseLeave me
on endSprite me
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.