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.
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:
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.
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.
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.
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.
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 MovieA 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.
Playback. These choices determine how Director MX will play the Flash movie.
Quality. These choices determine how well the movie plays in Director.
Scale Mode. The choices in the pop-down determine how the Flash movie will be scaled on the Director stage.
Rate. These choices determine the frame rate. Director calls this tempo?the rate at which the Flash movie will play.
|
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:
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.
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.
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.
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.
Tip
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 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:
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).
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.
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" end
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.
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.
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.
Tip
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.
Click inside the Text entry area of the Actions panel (see Figure 11.12) and enter the following code:
on (release) { getURL("event: showMovie"); }
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.
Select Save and Compact to optimize the Flash movie's playback. Publish the movie and quit Flash.
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.
Drag the button from the cast to a point just over the word "subway" in frame 1. Play the movie.
Note
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.