nightwares mini logoA brief introduction to Director

15. Get Outta Dodge

Letting the user quit your program.

Director 8.5 Shockwave Studio: A Beginner's Guide

Online reader support forum for the book

But there's a new problem now. If you compile and run the projector as it is currently, you have no ready way to quit the program!


Your computer will display "Hello, World" at you indefinitely.

That's a terrible design.

You need to build in a way for your user to quit the program once it's gotten its point across.

The quickest way to do this is to put a QUIT (or EXIT) button onscreen somewhere under "Hello, World".

Back to the Tool Palette!

Click once on the button tool (the one which looks like a button), then click somewhere on the Stage and type the word QUIT in the button that appears (or EXIT for Windows).

Ready? Not yet.

You have to define an action associated with that button; simply typing the word QUIT in it isn't enough.

The button you just created should appear in the Cast window, probably in box number four. Click once on it, then click the script icon at the top of the Cast window — this should look like a white box with lines meant to represent indented scripting in it. Another Script window will open — in this case, a Button script. In its window you will see:

  on mouseUp
    |
  end


With a cursor flashing between the lines, as it was with your Score script.

All you have to do to make your QUIT button a real QUIT button is add one word:

  on mouseUp
    QUIT
  end


This is telling Director (and the computer on which it's running):

"When the user releases the mouse button (on mouseUp), QUIT the program."

Note this event takes place on a mouseUp event, not a mouseDown event. This is a standard User Interface (UI) design; generally button events are not triggered by mouse action until the mouse button is released. This permits the user to cancel the action by dragging the mouse away before releasing the button. All well-written programs behave in this fashion.

As with the Score script you entered, note that there are no double-spaces in your button script.

Now you can close the script window and — hey presto — you have an authentic QUIT button.


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