Articles Archive
Articles Search
Director Wiki

Screen Saver

August 1, 1999
by Pat McClellan

Dear Multimedia Handyman,

I want to create a screen saver program that plasters the entire screen with graphics such as 50 small photos and keeps repeating until the mouse or keyboard is pressed. I have heard that this can be accomplished with the lingo commands list and MIAW. I have basic lingo experience but I have no clue about these commands,can you help.

Jim Moretti

Dear Jim,

There are 2 steps involved in your request. First, you'll need to creat a Director projector which recognizes the size of the screen and automatically adjusts itself -- and then quits when the mouse is moved or keyboard is pressed. Second, you'll need to convert that projector into a self-starting screensaver.

Step 2 is easiest. Go to and buy CineMac. It's a great program which will convert your Director Projector into a screen saver. Despite the name, it works great on both platforms. You can read a review of the product at buildArticle.php?id=99.

Now, let's create the projector. The screen saver you describe will involve placing a sprite at random locations around the screen (as many screen savers do). Start your movie by setting the stage size to be as large as the largest screen you expect to play it on. For the demo, I set the stage size to 1152 x 870. Even though the stage is this size, in most cases only a portion of it will be visible. That's the portion that we'll use for our sprite placement. This means that we'll want to know how big the playback screen is.

You can find the playback screen's size by using the deskTopRectList property. For example, open Director and the message window and do this:

put the deskTopRectList
-- [rect(0, 0, 1152, 870)]

As you can see, the result is a rect... but note that it is encapsulated in a list even though it is only one item. If you are using 2 monitors, you'll see a second rect list that represents the coordinates of your second monitor. For this demo, I'm going to assume that we're only using one monitor. In my startMovie handler, I'll take this first rect out of the deskTopRectList and then grab the 3rd and 4th values out of the rect list. These values are the right and bottom of the screen, which I'll store in global variables (gRightLimit and gBottomLimit).

on startMovie me
  global gRightLimit, gBottomLimit, gMouseLoc
  set screenSize = getAt(the deskTopRectList,1)
  set gRightLimit = the right of screenSize
  set gBottomLimit = the bottom of screenSize
  set gMouseLoc = point(the mouseH, the mouseV)
  set the keyDownScript to "halt"

Ignore the last two lines of the startMovie handler for now. I'll get to them later.

Now that we know the screen size, all we have to do is swap the cast members into the on-screen sprite and place the sprite at random within the limits of the screen. For maximum ease, place your 50 cast members in the first 50 spots in the cast. That way, we can just refer to the as member 1 to member 50.

On each exitFrame, we'll select a memberNum at random, select a locH and locV at random, then set the member and location of our sprite. Easy.

The last line of our exitFrame handler calls another handler named "testMouse" which appears below it. Test mouse simply checks to see if the mouse has moved since the last time it checked. If so, it halts the movie -- otherwise the movie continues. To check the mouse position, I use a global variable, which is initialized in the startMovie handler (one of those lines of code I told you to ignore before.)

on exitFrame
  global gRightLimit, gBottomLimit, gMouseLoc
  set memNum = random(50) 
  -- or however many graphics you have
  set newH = random(gRightLimit)
  set newV = random(gBottomLimit)
  set the member of sprite 1 = member memNum
  set the loc of sprite 1 = point(newH, newV)
on testMouse me
  global gMouseLoc
  set newMouseLoc = point(the mouseH, the mouseV)
  if newMouseLoc <> gMouseLoc then
    set gMouseLoc = point(the mouseH, the mouseV) 
  end if

So now we've set it up to display your images at random and quit if the mouse moves. You also want the movie to quit in two other situations: if a key is pressed, and if the mouse is clicked (even if it wasn't moved.)

The key press is really easy. It's the final line of code in the startMovie handler...

set the keyDownScript to "halt"

That simply halts the movie any time a key is pressed. You can accomplish the same result for a mouse click with this handler...

on mouseDown

A few final notes: all of these handlers are in a single movie script -- not tied to any frame or attached to a sprite. I have a frame script at the end of my score which simply loops back to the first frame so the movie keeps looping until it quits.

I use the lingo term "halt" instead of "quit". It has the same effect as quit on a projector, but when authoring, "quit" will quit your Director application, while "halt" will simply stop the movie from playing.

I set the sprite to "trails" ink, so that it continues to build the image with each frame.

And finally, Director 7 can now create what are called "slim" projectors. These are projectors which use the Shockwave player on the user's computer instead of packaging the playback engine in the projector itself. The result is that you can now create projectors which will fit on a floppy disk -- a key requirement for most screen savers. No problem converting slim projectors to screen savers with CineMac. You just have to assume that the user has Shockwave on their system.

Download a sample movie in Mac or PC format.
Download a free demo of MacSourcery.

Patrick McClellan is Director Online's co-founder. Pat is Vice President, Managing Director for Jack Morton Worldwide, a global experiential marketing company. He is responsible for the San Francisco office, which helps major technology clients to develop marketing communications programs to reach enterprise and consumer audiences.

Copyright 1997-2019, Director Online. Article content copyright by respective authors.