Not Just Stand-Alone

In the last module, you saw that MIAWs can extend your Director programs considerably, allowing conceptually related ideas to be clustered into satellite controls that don’t seriously affect the performance of your main program. In fact, you saw that these MIAWs would work quite well as stand-alone modules in their own right, and perhaps you even packaged them that way by making extra projectors of them.

But a MIAW doesn’t do a lot of good if all it does is sit there on the screen awaiting input, aloof in its own little universe. It might as well be its own projector if that’s all you want to do with it.

The real usefulness of MIAWs lies in the fact that they can communicate with each other and with their parent movies, allowing you to pass information to the MIAW that you want only it to handle, freeing your main movie up to do other things.

In this last module, we’re going to do exactly that, enhancing our thumbnail program even further.

Zoom!

Having thumbnails­even the generously sized ones we’ve created­is not always enough when you’re trying to sort images. Sometimes, you want to see that image in a full-screen mode before you can decide whether it belongs in the Trash, in the prewedding album, or in the post-wedding album.

Naturally, it would be very convenient to simply be able to enlarge the thumbnail to its full-screen size somehow, letting you get a look at it in all of its unshrunken glory. However, you don’t want to do that on your main list, thumbnail, and folder interface, because doing so would force you to resize the Stage every time the user wanted to see the full-sized view (or set up the image so it’s scrollable), and then all the controls you’ve so carefully created would no longer be available. Imagine the headaches you’d invite by trying to do all of that reprogramming!

Of course MIAW is the way to go here. We just need to get the image to open in its "regular" size in a MIAW, and to do that, we need to use tell, a Director keyword that causes one movie to talk to another. You can talk to any MIAW by using tell in conjunction with its variable container or window instance. The general grammar is as follows:

tell target

doCommands

end tell

target is, of course, the object containing your window; however, MIAWs can also do this with the Stage by using the command tell the stage. In other words, MIAWs can send commands to the Stage, as well as receive them.

doCommands can be any kind of Lingo you want executed. This can be a go to frame command, a command to run a handler, or even a call to sendSprite or sendAllSprites. Essentially, any command you can do in Lingo can be done in tell as well, the difference being that it is not the parent movie or source of the tell command that executes the code; rather, the target specified in tell performs the functions.

As an example, create a Director movie named main, and give it this movie script:
 

on startMovie
 
 
wChild = ( window "Child" )
wChild.fileName = "child"
open wChild

sMovie1 = the movieName

tell wChild
 

sMovie2 = the movieName


end tell

put "Main movie is" && sMovie1
put "Child movie is" && sMovie2

END startMovie


Naturally, I’ll need you to make a movie named "child" as well; you can give it a simple go the frame script. Then, run your main movie and note the feedback in the Message window.

Do you see that, even though you issued identical commands in your startMovie script, you got different results? This occurs because the second variable was set by a tell command; it was feedback from the child movie that we plugged into the second variable, not from the parent.

Your child movie could also have issued a tell command to the parent movie by using a call such as the following:
 

tell the stage
 
put "Hello from the child movie" && the movieName


end tell


Not a very interesting message, to be sure, but it would be coming from the child MIAW, not the parent movie, and that kind of command passing allows us to make our full-screen preview for our thumbnails.