nightwares mini logoA brief introduction to Director

10. What...?

Looking at the CheckColor() handler more closely.

Director 8.5 Shockwave Studio: A Beginner's Guide

Online reader support forum for the book

Line by line, here is what is happening.

  on CheckColor

This tells Director that what follows is a handler definition. Note there are no parentheses.

  if the colorDepth <> 8 then

This is checking the computer. In essence it's asking the system how many colors can be displayed. 8-bit color (or grey) returns a colorDepth value of 8; this means that the system is capable of displaying 256 colors or shades of grey. A lower number indicates fewer colors can be displayed; for example, 4-bit color is only 16 shades; 2-bit color is 4 shades, and 1-bit color is pure black-and-white. If the value is higher , say 16 or 24, there are even more colors accessible; we'll go into why this can be a problem later.

Since, in general, you will want your users to have machines capable of displaying at least 256 colors (especially if you use a lot of graphics in your programs), you need to have a way to test for 8-bit minimum color depth and warn the user if the system is not displaying enough colors. That is what the next line does:

  ALERT "Caution: This computer is set to something other than 256-color (8-bit) color mode." & RETURN & RETURN & "Some colors in this program may not be displayed correctly."

This command makes the system beep and then displays a dialog box containing the text in quotes and a button labeled OK. The & RETURN & RETURN & tells Director to put two RETURNs between the two quoted lines — a double-space that makes the message easier to read and understand.

Try it for yourself -- copy the ALERT line (but only the ALERT line), paste it into the Message window, and hit RETURN. You'll see a sample of what the ALERT command does.

  end if

This terminates the if...then test. Without an end if, Director will return an error when you try to close the Script window. It's telling the program that it's time to finish testing a condition. You must insert an end if (or its equivalent) for every if...then statement you make.

  END CheckColor

This tells Director that you have finished the definition of this handler. Note, again, that there are no parentheses.


1. Introduction

2. Definition of Objectives

3. Specific Objectives

4. Stage Size

5. Stage Location

6. Setting the Stage's Color

7. Beginning to Enter Script

8. A bit More About the StartMovie() Handler

9. Entering Another Handler

10. A Break-down of the CheckColor() Handler

11. A Quick Test

12. Adding Text to the Stage

13. Preparing to Enter a Frame Script

14. Entering the Frame Script

15. Adding a Quit Button

16. The Progress so Far

17. Preparing to Add a Menu

18. Discussion of Menu Requirements

19. Preparing the Menu Storage Member

20. Entering Menu Functions for Macintosh

21. Entering Menu Functions for Windows

22. Efficientlly Handling Multiple Menus

23. Preparing to Insert the Menus Onscreen

24. Adding the Menu Installation Handler

25. Discussion of the Menu Installation Handler

26. Adding Code for an About Box

27. Review of the Scripts

28. Creating a Projector and Running it