Director Tutorials

 

Using Movies In A Window (MIAWs)

This technote covers MIAW Lingo for Director MX and earlier versions. Director MX 2004 changes the way MIAWs work and are displayed. The Lingo is different and so what is covered here will not work in MX 2004+. To view MIAW Lingo for MX 2004, go here.

Movies in a Window (MIAWs) are a useful way of layering movies over each other or separating discreet 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.

The following outlines the process of creating and using MIAWs

Opening and Closing MIAWs

Opening a MIAW
A MIAW can be opened very easily with the following:
open window "windowName" -- verbose syntax
or
window("windowName").open() -- dot syntax

windowName represents the name given to the MIAW (which you will see how to do later) or the file name of the movie acting as the MIAW. If the name has not been assigned to the window and no file of that name exists, the Open File dialog box appears.

Example
The following opens the window named "Instructions":
window("Instructions").open()"

Closing a MIAW
A MIAW can be closed with the following:
close window "windowName" -- verbose syntax
or
window("windowName").close() -- dot syntax

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
forget window "windowName" -- verbose syntax
or
window("windowName").forget() -- dot syntax

Example
The following closes the window named "Instructions" and removes it from memory:
window("Instructions").forget()"

Listing the current movies in windows
The windowList property displays a list of all known MIAWs in the main movie.

Example
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 = [ ]

Assigning a movie to the MIAW
To assign the file name of a movie to the window use the following:
window("windowName").fileName = "movieName"

Example
The following associates the movie with the file name "instruct1" to a MIAW named "Instructions".
window("Instructions").fileName = "instruct1"
tatement(s)

MIAW appearance

Setting the type of MIAW
There are a number of window types that are available, such as an alert box (type 1), movable, fixed, with or without title bars. The window types differ between Windows and Macintosh platforms.

You can set the window type for a MIAW with the following:
window("windowName").windowType = windowNumber
windowNumber
is the number representing the type of window.

Example
The following sets the MIAW named "Instructions" to a movable window without a size box or zoom box, reference number 4.
window("Instructions" ).windowType = 4

Setting the visibility of a MIAW
You can determine whether a MIAW is visible or not.
To make a window visible use:
window("windowName").visible = TRUE

The visibility property is useful when you need to open a window quickly and when used together with the preload command. To preload a movie use the following:
preLoadMovie "movieName"

This preloads the data and cast members associated with the first frame of the specified movie. Preloading a movie is useful to start up a movie faster. It can be used prior to a using a go to movie or play movie command or opening a MIAW.

Setting the title of 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.

You give your MIAW a title use with the following:
window("windowName").title = "windowTitle"

Example
The following sets the title of MIAW named "Instructions" to "Keyboard Controls for this Game".
window("Instructions" ).title = "Keyboard Controls for this Game"

Setting the title visibility of a MIAW
Above, we set the title of a MIAW. There may be times when you don't want the title to be visible. You can do that with the following:
window("windowName").titleVisible = FALSE

Setting the name of a MIAW
The name window property determines the name of the specified window in windowList (discussed towards the top of this page). This is different to the title property.

You change your MIAW name use with the following:
window("oldWindowName").name = "newWindowName"

Setting window size and location for a MIAW
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 the bottom right corner of the rectangle.

You locate and size your MIAW, use with the following:
window("windowName").rect = rect(winLeft, winTop, winRight, winBot)

Example
winLeft = (the stageRight)
winTop = (the stageTop)
winRight = (the stageRight + 320)
winBot = (the stageTop + 240)
window("Instructions").rect = rect(winLeft, winTop, winRight, winBot)


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 width of the Stage in pixels is determined by the stageRight - the stageLeft. The height of the Stage in pixels is determined by the stageBottom - the stageTop.

In the above example, the window rectangle has it's top left corner aligned with the top right corner of the Stage. The bottom right corner is 320 across and 240 down. This represents a window size of 320 wide and 240 pixels high placed flush against the right edge of the Stage.

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:
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:
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.
window("windowName").moveToFront()
or
window("windowName").moveToBack()

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.

Example

This statement determines whether the window "Instructions" is currently the frontmost window and, if it is, brings the window "Try This" to the front:
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
Movies can interact with each other by sending Lingo messages back and forth This is done with the tell command.

tell windowName to statement(s)
tell windowName
....statement(s)
end


To send a message to the main movie, use:
tell the stage to statement(s)

MIAW events

Use these event handlers to contain Lingo that you want to run in response to events in a movie in a window:

on activateWindow
on openWindow
on closeWindow

on resizeWindow
on moveWindow
on zoomWindow