The Flash MX 2004/Director MX Connection

The capability to use Flash MX 2004 movies inside a Director MX movie is a relatively new feature. The beauty of a Flash movie inside of Director is size. Flash MX 2004 movies are composed of vectors, and these movies are scalable and optimized for web playback.

Adding a Flash movie to a Director presentation is not terribly difficult. It is imported into the Director cast, and, as such, can be manipulated in Director just like any other cast member. What makes the use of Flash in Director so appealing is that tweening effects that required multiple cast members can be done in a relatively small Flash movie that only requires one cast member.

The other new feature is the capability of Director to access the Flash Communication Server MX. Suddenly, dynamic data is a definite possibility in a rich media authoring environment. We will be spending a lot of time examining this feature in the following chapters.

Naturally, Director offers the capability to control nearly every Flash property?playback, rewind, size, location, quality settings, and even sound control?using Lingo commands. The only downside is that you shouldn't get carried away and use a number of Flash movies in the Director presentation. Each Flash sprite on the Director stage will load its own instance of the Flash Asset Xtra. The result will be serious performance degradation as the number of Flash sprites on the stage increases. Bottom line: The fewer Flash sprites on the Director stage at any one time, the better.

Finally, add a Flash .swf file to a Director Shockwave movie, and you have an unbeatable combination. The Flash .swf, thanks to its vectors, loads much more quickly into a browser than other media. A common use for Flash movies in a Director presentation is as a splash screen that plays an animation while the rest of the Director content streams into memory. Another is embedding entire Flash web sites into a Director movie.

We are going to examine three aspects of working with Flash in Director. They are:

  • Importing and playing a Flash file in Director.

  • Round trip editing between Flash and Director.

  • Controlling a Flash sprite through Lingo.

Importing and Playing a Flash MX 2004 File in Director MX

Though any Flash movie can be imported into Director, there are still a couple of rules. First, any Flash 2.0 movie or later can be imported into Director. Second, the Flash MX 2004 file that is placed into Director is the published .swf file from Flash MX 2004.

Finally, make it a practice to include a copy of the original .fla file with the .swf. Just keep in mind that the .fla file can't be imported into Director MX. You will need the .fla if you need to edit the movie from Director MX. To import a Flash MX 2004 .swf into Director MX, follow these steps:

  1. Launch Director MX. A Flash movie is not simply imported into Director. It is inserted using the Flash Asset Xtra mentioned earlier. Select Insert, Media Element, Flash Movie. This opens the Flash Asset Properties dialog box shown in Figure 11.9. Click the browse button and navigate to the Flash folder in the Chapter exercise file you downloaded from the book's web site. Open the Import Folder and select the Movie1.swf file. Click Open to be returned to the Flash Asset Properties dialog box. The path to the file is located in the Link area, and a thumbnail is visible over the Play button. For a full explanation of the choices, see the sidebar "All Those Choices for One Little Flash Movie." Deselect Linked and click OK. The Flash movie is added to the Director cast.

    Figure 11.9. The Flash Asset Properties dialog box enables you to determine how the movie plays in Director, its scaling properties, and even the location from where the Flash movie will play.


  2. Select Windows, Library Palette. When the Code Library Palette opens, select the Library tab. Click the palette Options button (the square one on the left) and select Navigation.

  3. Drag the Hold on Current Frame behavior from the panel to frame 1 of the Frame Scripts channel, the channel directly above the timeline. Release the mouse, and the script is dropped into the frame.

  4. Open the cast (Command-3 for Mac users, Control-3 for PC users) and drag the Flash movie into frame 1 of channel 1. Depending on your preferences, the Flash movie will span frames 1 to 26 of the channel. Click the square handle at the end of the span and drag it back to frame 1. When finished, your score should resemble that shown in Figure 11.10.

    Figure 11.10. The Flash movie is placed on the Director stage and ready to be tested.


  5. Play the movie. You will notice that all the ActionScript embedded in the Play button is fully functional in the Director movie.

All Those Choices For One Little Flash Movie

A natural question at this point is, "What's with all the choices in that dialog box?"

Media. These choices locate the files and set the preload.

  • Linked: This links the Flash file to the Director movie from its original location. Deselect this to load the Flash movie into the Director cast.

  • Preload: Select this, and the entire Flash movie is loaded into memory before it starts playing. This is only available if the Flash movie is linked. Flash movies playing from the Director cast always load completely into memory before they play.

Playback. These choices determine how Director MX will play the Flash movie.

  • Image: Select this to see the Flash movie. Deselect it, and the movie will be invisible.

  • Sound: Select this, and any sound in the movie will play.

  • Paused: Stops the Flash movie on its first frame.

  • Loop: Select this, and the movie will return to frame 1 of its timeline and start playing all over again.

  • Direct To Stage: This actually does two things. The first is that it optimizes playback of the Flash movie. The second is that the Flash movie, regardless of its channel location, will always be played in front of everything else.

Quality. These choices determine how well the movie plays in Director.

  • High Quality: Select this to play the Flash movie with anti-aliasing turned on. This will slow down performance.

  • Auto-High: Select this to have Director start the movie with anti-aliasing turned on. If performance is affected and the frame rate can't be achieved, Director will automatically turn it off.

  • Low: Select this to play the Flash movie with anti-aliasing turned off. This will speed up performance.

  • Auto-Low: Select this to have Director start the movie with anti-aliasing turned off. If performance is not affected and the frame rate can't be achieved, Director will automatically turn it on.

Scale Mode. The choices in the pop-down determine how the Flash movie will be scaled on the Director stage.

  • Show All: Select this to maintain the movie's aspect ratio when scaling. This is a fancy description for proportional scaling.

  • No Border: If you aren't using proportional scaling, the top or the sides of the Flash movie may be trimmed off and replaced by a border. This selection disregards the border.

  • Exact Fit: Stretches the movie to fit the dimensions of a sprite and disregards the aspect ratio.

  • Auto-Size: Select this if you are going to be skewing, rotating, or flipping the movie.

  • No Scale: Select this to place the movie on the stage with no scaling.

Rate. These choices determine the frame rate. Director calls this tempo?the rate at which the Flash movie will play.

  • Normal: Select this to play the Flash movie using the frame rate established in Flash.

  • Fixed: Select this to manually set the playback rate. Just be aware that if the Director movie's frame rate is 15 frames per second, you can't have the Flash movie play faster than the Director movie.

  • Lock-Step: Select this to have Director play a Flash frame for each Director frame.

Round Trip Editing Between Director MX and Flash MX 2004

Flash members can be edited from the cast in Director, providing that:

  • You have the .fla file in the same folder as the .swf.

  • You didn't select Linked in the Flash Asset dialog box when you imported the file. If the file is linked, it can be unlinked by selecting the cast member and opening the Director MX Property Inspector. Click the Flash tab and then click the Options button to open the Flash Asset Properties dialog box.

  • Flash MX 2004 is the External Editor in the Director MX Preferences. If you installed Flash MX 2004 before you installed Director, it will automatically be made the default editor.

To edit a Flash cast member in Flash MX 2004, follow these steps:

  1. With your Director movie open, select the Flash movie and turn off the Linked status in the Flash Asset properties. Double-click the Flash member in the cast.

  2. The Locate Source File for Member dialog box will open. Navigate to the Edit folder (in the exercise's Flash folder) containing the .fla file and click Open.

  3. This will launch Flash. When Flash opens, change the color of the Play button symbol in the Library from light blue in the Up state to dark blue.

  4. When you are finished, click the Done button on the Document window, and the change will be saved, Flash will quit, Director will reopen, and your change will be visible on the Director stage.


That second step is only done once. When Director knows the path to the file, it will never forget it. If you want to avoid that step completely, open the Flash Member properties in the Property Inspector. Click the Browse button under the file name input box and navigate to the .fla file.

Flash/Director Communication

Flash movies communicate with Director movies through the ActionScript event getURL. This seems a little odd at first?using a getURL action to send a message to Director. In fact, it makes sense because that is how Flash traditionally talks to browsers. In this instance, we are going to use a Flash button that, when released, sends a Lingo message to Director. That message is simple: When the button is pressed, the Flash Button is going to tell Director to execute a Lingo script named showMovie.

Here's how it works:

  1. Open the Subway.dir movie located in a folder named Code inside the Flash folder of the Chapter 11 Exercise Folder downloaded from the book's web site. When the movie opens, open the score (Control-4 on PC or Command-4 on Mac).

  2. You will notice (see Figure 11.11) that two areas of the score are used. The first area, frame 1, will hold the Flash button. The second area, frame 5, contains a digital video of the subway train used earlier. Above the frame is an inverted triangle with the word "Movie" beside it. This is a marker, and it is traditionally used for frame-based navigation in Director. If you are a Flash user, "Markers" is a Director term for Flash's "Frame Labels." This marker is important because when the Flash Button is clicked, the Director playback head will move to the marker.

    Figure 11.11. The Director movie is just about ready to go. They key to the whole project is the marker named Movie that is sitting over frame 5.


  3. To write the script that controls the move to the marker, select Window, Script (Command-0 (Zero) on Mac or Control-0 (Zero) on PC). A blank movie script will open. Enter the following code:

    on showMovie
      go to frame "Movie"

    You have just written a script that starts running when the movie launches, which is why it is called a movie script. The script, in plain English, says, "When the 'showMovie' handler is called?on showMovie?send the director playback head to a frame named 'Movie.'"

    The neat thing about movie scripts is that they just live in the cast. They don't need to be attached to anything.

  4. Close the movie script. Save the changes to the Director movie and open the BlueButton.fla file in the exercise folder. This will open Flash.

  5. When the Flash movie opens, select the button on the stage. Select Window, Development Panels or press the F9 key to open the Actions panel.


    If you want to add ActionScript to a Button, always select the button on the stage before you open the Actions panel. Flash MX 2004 will recognize the selected object as a button, meaning that you can add button events in the Actions panel.

  6. Click inside the Text entry area of the Actions panel (see Figure 11.12) and enter the following code:

    on (release) {
          getURL("event: showMovie");
    Figure 11.12. The code that makes things happen in Director is added to the button's on (release) event.


    The key here is "event:showMovie". The key word event sends the event message to Director. The event Director is being asked to execute is the showMovie handler from the Director movie script.

    With this last bit of code from Flash, you can see how things will happen in Director. When the button is released, the Flash Button sends an event message to Director telling it to run a handler named showMovie. Director scoots through its particular script hierarchy looking for the handler. It finds it in the movie script and moves the playback head to frame 5 of the Director movie. The end result is that the video in that frame starts to play.

  7. Select Save and Compact to optimize the Flash movie's playback. Publish the movie and quit Flash.

  8. Return to the Director movie and insert (Insert, Media Element, Flash Movie) the Flash button into the Director cast. When the Flash Asset dialog opens, be sure to deselect Direct To Stage.

  9. Drag the button from the cast to a point just over the word "subway" in frame 1. Play the movie.


In the preceding step, you were told to deselect Direct To Stage. The reason is that this option essentially places the Flash button in front of everything when the screen is drawn by the system. This means that when you move to frame 5, you may actually see the Flash button in the frame. What makes this so disturbing is it isn't in the frame. Essentially, what you would be looking at is a ghost image as a result of Director moving faster than the system can redraw the screen.