Articles Archive
Articles Search
Director Wiki

Creating a Movie In A Window

January 8, 2001
by Will Turnage

Dear Handyman,

I am currently working on a project where my main movie has a 'menu' button. When you click on that button, I want a different window to open containing the menu. How can i do that?


It sounds like you're ready to start dealing with Director's movie-in-a-window, more commonly referred to as a MIAW. MIAWs are separate Director movies running in a different window from the main movie on screen. These windows can be moveable and resizeable, and they run independent from your main movie.

While MIAWs have separate casts and scores from your main movie, all MIAWs have access to any global variable in your main movie. Since MIAWs can easily exchange data between movies, they are often used to display custom dialog boxes, statistics, preferences, or any other content outside of the stage. The biggest disadvantage of a MIAW is that it doesn't work in Shockwave, so its use is limited to desktop and CD-ROM production.

If you want to use and MIAW in your project, there are five steps you should follow.

Step 1: Create your MIAW using a global variable

When you create a MIAW in Director, you need to store the reference to the MIAW in a variable. Not only does this make managing the MIAW much easier, but by making it a global variable, you give the stage and all MIAWs access to it and its contents. Creating a MIAW is as simple as:

gWin = window ("testMIAW")
put gWin
-- (window "testMIAW")

When you created this window object, you automatically added the window object to the windowList. The windowList is a system property of Lingo that contains a reference to every single window used in your current project. For instance,

gPrefWindow = window("Preferences")
gQuitWindow = window("QuitDialog")
gSoundWindow = window("SoundOptions")
put the windowList
-- [(window "Preferences"), (window "QuitDialog"),
    (window "SoundOptions")]

If your project has many MIAWs, the windowList is an easy way to see how many windows you have created and are currently loaded into memory.

Step 2: Define the content and appearance of your MIAW

Once you've created your MIAW variable, you need to specify some information about your MIAW before it can be opened and displayed on screen. Most of these settings are optional, but the one that is definitely required is the filename, that is the exact name of the movie that will be displayed in your MIAW.

gWin.filename = "miaw.dir"

There are three other basic properties you can specify before opening your MIAW. All of these are optional, but greatly affect the appearance and functionality of your MIAW:

rect - The rect property not only tells Director what the size of your window will be, it also tells Director where it will appear on the stage. For instance, if the Director movie you want to open as a MIAW has a size of 320x240, you can set the rect of the MIAW many different ways. If you set the rect equal to rect(0,0,320,240) , then the MIAW will open in the upper left hand corner of your screen. However, if you set your MIAW's rect equal to rect(100,100,420,240), then it will open 100 pixels away from the left and top of the screen.

The rect of a MIAW doesn't have to be the exact same size as the source movie. For instance, in the previous example, you could also have set the rect of the MIAW equal to rect(100,100,200,200). In this instance, the MIAW would have displayed only a small portion of your Director movie. Setting the rect of a MIAW to a smaller size will never resize your original movie, instead it will always crop off the edges.

windowType -The windowType property of a MIAW is an integer that determines the appearance of the actual window. This number determines whether or not your window has such UI elements as a title bar, a resize handle, or a close button. There are 10 different possible values for the windowType, described in Director's help section as the following:

0 - Moveable, sizeable window without zoom box
1 - Alert box or modal dialog box
2 - Plain box, no title bar
3 - Plain box with shadow, no title bar
4 - Moveable window without size box or zoom box
5 - Moveable modal dialog box
8 - Standard document window
12 - Zoomable, nonresizeable window
16 - Rounded corner window
49 - Floating palette, during authoring (in Macintosh projectors, the value 49 specifies a stationary window)

To actually see what each windowType looks like on Mac and Windows, download the sample movie at the end of the article.

modal - The modal property of a MIAW is a boolean value that determines whether or not your MIAW can interact with other movies. If you set the modal equal to TRUE, then when you open the MIAW you will not be able to interact with any other windows including the stage. This is useful when your MIAW contains a dialog box that the user must answer before continuing with the rest of the program.

Step 3: Open your MIAW

Once you have created your window, and set its parameters, then you're ready to actually open and display your MIAW. It's as easy as

When you create your original MIAW variable and assign a fileName to it, that's when Director loads the movie into memory. This is useful to know because if you have a large MIAW, oftentimes it can take a second or two to create the window object and load it into memory. If you want your movie to open faster you might consider creating all of your MIAW variables when your program starts, that way you can open them later without making the user wait for the movie to load.

Step 4: Communicating between your MIAW and the Stage

Once your MIAW has been opened, then it can run independently or it can interact with the Stage or other MIAWs. To interact with other movies, all you need to do is use the tell command. To use the tell command, simply surround the code you want to send to another window with the terms tell (window object) and end tell. For instance, if the Stage wanted to send a command to your MIAW, it might look like this:

global gWin

on mouseUp me

  tell gWin
    member("windowName").text = EMPTY
    member("windowType").text = EMPTY
    member("status").text = EMPTY
  end tell


or to flip it around, the MIAW could tell a command to the stage too.

on mouseUp me

  tell (the stage)
    go "quit"
  end tell


Step 5: Closing and Forgetting your MIAW

If your MIAW has a close button in the title bar, then the user can close the MIAW by clicking on it. If you don't have a close button, then you can achieve the same thing through Lingo by saying:


In both of these instances, though, the MIAW is closed and the user can't see it, but the window object still exists and is still loaded in memory. It's even still part of the windowList. This is helpful, because if you need to open the window again, all you have to do is call the open command.

However, multiple MIAWs can eat up memory, so if you need to clear MIAWs out of memory, you need to use the forget command. Using forget not only closes the MIAW, but it also deletes references to it in the windowList. This is a very important step to include especially when authoring. Often, if you don't forget your MIAWs they will keep eating up memory until your program crashes.

So now you know the basics of how to create, open, interact with, and close a MIAW. If you want to know more about MIAWs, there are many more handlers and properties not covered in this article. Just go to the Lingo Dictionary and look under the movie in a window section.

Also, if you want to see some of the basics in action, check out a sample Director 7 movie available for download in Mac or Windows format.

A sample Director 7 movie is available for download in Mac or Windows format.

Will Turnage is a multimedia programmer based in New York City. In addition to his weekly role as Director Online's Multimedia Handyman, he is also the Technology Director for Sony Music's Client Side Technologies Group. You can read more about his work at

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