Lingo 3 Tutorial: Events and Handlers
READING: We are about to get into a little deeper waters now. You have to read carefully Chapter 8 of the D8D and answer all the questions within this tutorial
Objects have properties (can remember facts) and methods (can do things).
the run of a program, Director is watching for "events".
but they are many more than them. There are at least 27
probably more than you can
point out the ones that we view as really necessary.
mouseUp (rightMouseDown, rightMouseUp)
for now: activateWindow, deactivateWindow, openWindow,
Sprite -> Cast -> Frame -> Movie -> Director
For each of the above objects you can write event handlers to respond to the event. Once a handler is executed, the event stops propagating, unless the handler contains the pass command. A pass command will allow the propagation of the event up the hierarchy.
PLAYBACK VISITS FRAME AFTER FRAME
start this tutorial look at the file "playbackHeadEvents.dir". Make
sure the "loop playback" button is off (->|)
Q1: Who sends the messages?
on the "loop playback" button. What do
you expect to happen? Test it.
run the movie "userActionsEvents00.dir",
and click on the red dot. You get the message
Now edit the sprite and frame scripts to Pass the messages
after you process them.
Edit the script of the cast member to pass the message.
What is the behavior of the clicks now?
the movie "userActionsEvents01.dir", and click
on the red dot. Now you capture messages about mouseDown
instead of mouseUp.
again, open the movie "userActionsEvents02.dir",
and bring your cursor over the red dot. Notice the reporting
of the script for
Q5: Why there is no reporting mouse DOWN on the sprite?
-> Cast -> Frame -> Movie -> Director
Sing it 56 times every morning until you memorize it completely!
MOUSEUPOUTSIDE AND THE locH SPRITE PROPERTY
the movie "userActionsEvents03.dir",
and bring your cursor over the red
dot. Notice the behaviour of the
script for mouseWithin now makes you chase the ball.
Try to click on the dot and release slowly.
Hear the beep.
Observe the behavior of the script
Q6: Why the mouseUpOutside is not activated
when you just click outside the dot?
Q7: What other properties you can you guess exist for a sprite? How can you find out?MOUSEENTER, MOUSELEAVE AND THE visible PROPERTY
Open the movie "userActionsEvents04.dir", and bring your cursor over the red dot. When you move the cursor over the red dot, the text "WOW" to appear on the dot, and when you move the cursor away from the red dot, the text disappears. (Many programs' UIs have such a popup window these days, to explain what will happen if you click a button.)
Q8: How do you do that?Guess and verify your answer by looking at the script.BOUNCE UP AND DOWN
the movie "userActionsEvents05.dir",
run it, and try to guess what the scripts look like.
your guess was right or find out why it was not.
Q10: Modify the movie so that the ball bounces up and down, never sinking to the bottom for good. Explain how to do that.
TIME ACTIVATED EVENTS
Q11: Describe a situation in which the first way
is useful and another in which the second way is
WHERE TO PUT THAT SCRIPT?
So, you have figured out that you need to write a script, and what type of script it should be (sprite, cast member's frame's or movie's).
But where do you find the actual location that will contain your script? Here is some help:
Maintained By: Takis Metaxas