Using Movies In A Window (MIAWs)
Movies in a Window (MIAWs) are a useful way of layering movies over each
other or separating distinct elements of your application. They are effective
for things like dialog boxes, toolbars, menus, instructions panels. MIAWs
can even be used to create your own development tools.
When you create and open a MIAW, Director will be running multiple movies at once. This is useful to separate elements of your application but must be used cautiously as the more movies you have running the higher the overhead on your computer's CPU.
Creating MIAWs is relatively simple. The difficult part is planning when to use them. MIAWs can be created with one line of Lingo, but to gain full control the properties, such as MIAW size, location, appearance, it is worthwhile setting all them yourself rather than relying on the default settings.
Director MX 2004 changes the way MIAWs work and are displayed. The Lingo is different to earlier versions and so old MIAW LIngo will not work in MX 2004. This page covers MX 2004 Lingo. For MIAW Lingo in MX and earlier, go here.
The following outlines the process of creating and using MIAWs
- Create / Declare window.
- Assign a movie to the window (only necessary if filename and window name are different)
- Open the window and play the movie.
- Remove the window from memory when no longer needed.
Creating / Declaring a MIAWs
A MIAW first must be created (also called declared)
with the following:
Lingo: window().new ("windowName")
windowName represents the name and title given to the MIAW (we will look more at titles later) as well as assigning a movie with the same name to play in this window.
The above creates a MIAW named "Instructions" and linked to a movie with that name.
Assigning a movie filename to a MIAW
If you want the the MIAW to have a different
name from the filename, you can set it by doing the following:
window("windowName").fileName = "movieName"
window("Instructions").fileName = "instruct"
The above associates the movie with the file name "instruct" to a MIAW named "Instructions".
Opening and Closing MIAWs
Opening a MIAW
Once a MIAW has been declared, it can be immediately
opened using the following:
or combining the MIAW declaration and opening
The above creates a window and then open it. The window name and filename correspond to "Instructions":
To open a window quickly it can be the preload command can be used. To preload a movie use the following:
Closing a MIAW
A MIAW can be closed with the following:
Closing a window that is already closed has no effect. Closing a window does not remove it from memory. To do this, you need to use the forget window command below.
Closing a MIAW and removing it from memory
The above closes the window named "Instructions" and removes it from memory.
Listing the current movies in windows
The windowList property displays
a list of all known MIAWs in the main movie.
The following statement displays a list of current MIAW names in the Message window.
put the windowList
This statement clears the windowList, in other words closes all windows.
the windowList = [ ]
Setting the Type of MIAW
There are three window types - document, tool
or dialog. You can set the window type for a MIAW with
Lingo: window("windowName").type = #property
window("Instructions" ).type = #tool
Setting the Title to a MIAW
The title window property determines the title that appears in a window's
title bar. Giving your MIAWs their own title is useful if you want a long
title bar for the window, but this does not represent the window name of
the MIAW. To set the title of a MIAW, use the following:
Lingo: window("windowName").title = "windowTitle"
window("Instructions").fileName = "Keyboard Controls for this Game"
Setting the titlebarOptions
The titlebarOptions specifies the properties of the title bar of a window. Properties include #icon, #visible, #closebox, #minimizebox, #maximizebox, #sideTitlebar (Macintosh only).
Lingo: window(windowName).titlebarOptions.property = value
window("Instructions" ).titlebarOptions.icon = member("smallIcon")
The statements above sets the icon property to the bitmap cast member named smallIcon.
Setting the window size and location
To specify the location and size of a MIAW, you need to use the rect
property. The rect specifies a rectangle with points in the
following order - left, top, right and bottom. This can be thought of as
two sets of coordinates x1,y1 representing the top left corner of
the rectangle and x2,y2 representing the bottom right corner
of the rectangle.
You locate and size your MIAW, use with the following:
Lingo: window(windowName).rect = rect(winLeft, winTop, winRight, winBot)
winLeft = (the stageRight)
winTop = (the stageTop)
winRight = (the stageRight + 320)
winBot = (the stageTop + 240)
window("Instructions").rect = rect(winLeft, winTop, winRight, winBot)
The above example sets a MIAW window sized 320 x 240, located with the top left edge aligned to the top right edge of the main window (the stage).
We use the stageRight and the stageTop functions. Along with stageLeft and stageBottom, these functions indicate where the Stage is positioned on the desktop. The stageRight returns the right horizontal coordinate of the Stage relative to the upper left corner of the main screen's desktop (considered to be point 0,0). The stageRight is equal to the stageLeft plus the width of the Stage in pixels. The stageTop is equal to the stageBottom plus the height of the Stage in pixels.
If the size of the rectangle specified is less than that of the Stage, the movie is cropped in the window, not resized.
Scaling a MIAW
As seen above, the rect window property allows you to set
the size of the MIAW and crop it by setting the rectangle window to an area
smaller than the MIAW. To scale a MIAW, you can use the drawRect
property. This scales as well as locates a MIAW as in the rec
property. This property does not rescale text and field cast members. Scaling
bitmaps can affect performance.
You scale your MIAW with the following:
Lingo: window(windowName).drawRect = rect(winLeft, winTop, winRight, winBot)
You can return a MIAW to its original size and position after it has been dragged or its rectangle has been set using the following:
Lingo: window(windowName).rect = window(windowName).sourceRect
To control whether a movie appears in front of or behind other windows
Use the moveToFront and moveToBack commands.
the frontWindow is a system property that indicates which MIAW is currently frontmost on the screen. When the Stage is frontmost, front window is the Stage. When a media editor or floating palette is frontmost, the frontWindow returns VOID. This property can be tested but not set.
This statement determines whether the window "Instructions" is currently the frontmost window and, if it is, brings the window "Try This" to the front:
Lingo: if the frontWindow = "Instructions" then window("Try This").moveToFront
Minimizing a MIAW
On Windows, appMinimize causes a projector to minimize to the Windows Task Bar. On the Macintosh, appMinimize causes a projector to be hidden. Once hidden, the projector may be reopened from the Macintosh application menu. This is useful for projectors and MIAW's that play back without a title bar.
Communicating between windows
MIAWs can interact with other MIAWs by accessing a window's movie property.
With this property, you can access the movie's handlers, variables, members,
and so on.
window("MIAW").movie.member(1).name = "changed name"
For a MIAW to interact with the main move, use "stage"
window("stage").movie.member(1).name = "changed name"
Use these event handlers to contain Lingo that you want to run in response to events in a movie in a window:
on trayIconMouseDown (Win only)
on trayIconDoubleClick (Win only)
on trayIconRightMouseDown (Win only)