• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint

Logging Events

You used Director's Message window in Lesson 16 to receive trace output and test simple equations. In fact, you can use the Message window to test many of Lingo's commands. You can use Lingo's put command to direct output (results) from a function to the Message window. This feature allows you to log information as you work.

Open the Cast window if it is not already open. Double-click cast member 1 to open the Movie Script window for editing.

Figure .

The setStatus handler is at the top of the script. It currently sets the text of the Status cast member; however, because Director is constantly generating events, no sooner is one event displayed than another appears to take its place. You don't have time to read the text before it disappears from the screen.

Click the Script window and modify the setStatus handler by adding the line shown here in bold:

on setStatus newStatus
  put newStatus
  member ("status").text = newStatus

Now when this handler is called, it will not only update the Status field, but it will also write the information in the Message window so you can read it even after new output arrives. (Eventually, though, the oldest messages will be discarded if there are a lot of messages; the Message window does not have sufficient memory to record all messages indefinitely.)

Close the Script window and play the movie again. Let it run for a few seconds and then stop it.

As before, the status display changes very rapidly. However, the status information now appears in the Message window as well.

Choose Window > Message to open the Message window (Windows Ctrl+M, Macintosh Command+M).

The Message window appears, and the last few messages are visible. If you scroll back, you can see the previous messages as well.

Figure .

By studying the messages, you can see what is happening: Director generates a prepareFrame message when it prepares to draw a frame and then an enterFrame message when it has actually drawn the frame. At that point, Director reports an exitFrame event to indicate that it is about to leave the current frame. Then the cycle repeats. Even if Director were looping on a single frame, the sequence would be the same.

Save your work.



Not a subscriber?

Start A Free Trial

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint