Using .SWF Files in Macromedia Director Flash

Macromedia Director 8.5 is the multimedia authoring application used to create dazzling multimedia-rich DVD-ROMs, CD-ROMs, and Shockwave-enhanced Web experiences.

The most exciting news for the 8.5 release is the under-the-hood Intel 3D technology that enables Shockwave to use high-impact, textured, 3D graphics and models. Since version 6.5, you can import Flash movies (as .SWF files) via the Flash Asset Xtra. With version 8.5, you can take even more control of your .SWF movies in Director. Moreover, the latest versions of the Shockwave plug-in automatically install the Flash Asset Xtra on Web browsers. That means that you can count on Shockwave-enabled visitors being able to view your Flash-Director Shockwave content. But why would you want to use Director in combination with Flash in the first place? We answer that question next.

Benefits and limitations of Flash movies in Director
Flash 5 has been another monumental leap forward for Flash interactivity. With the additional advanced ActionScripting that Flash can now employ, many of the previous Flash-Director scenarios or workarounds are no longer needed. However, if you’re already familiar with Director and Lingo (Director’s scripting language), then you may find integrating .SWF files into Director projects easier than learning advanced scripting with ActionScript in Flash 5. The following list reviews some of the benefits and drawbacks of using Flash movies in Director projects.

  • Vector control: Even though Director has vector shape-drawing tools, it doesn’t use the same intuitive drawing mechanism that Flash does. Use Flash for any complex vector drawing and animation, and then bring it into your Director project.
  • Implement existing projects: With the ability to use Flash movies in Director, you need not duplicate efforts if material already exists in one format or the other. Thus, if you’ve already developed some cool animations in Flash for your company’s Web site, you can reuse the same Flash .SWF files in your Director projects.
  • Use media types that are not available in Flash: Director’s architecture can be expanded with the use of Macromedia’s (or a third party’s) Xtras. Even though Flash 4 and 5 can import QuickTime movie files, it can only export QuickTime Flash movies it can’t export .SWF files that contain QuickTime movies. However, you can import QuickTime movies, as well as many other media types, such as 3D Studio MAX models, into Director and that can be viewed and controlled in Shockwave Director movies. Some audio file formats, such as AU and MIDI, are not supported by Flash 5. Director 8.5 natively supports AU import. With the proper Xtras, you can use MIDI music with your Flash movies in Director.
  • Audio support: In versions of Director before 7.02, Flash audio could not play simultaneously with Director sound channels. Now, you can control the global property soundMixMedia to mix Flash sounds with Director score sound channels.
  • Flash frame rate control: Ironically, you have more control over a Flash movie’s frame rate in Director than you do natively within Flash 5. In Flash, the movie’s frame rate is fixed throughout the entire movie once it is set in the Modify➪Movie dialog, it cannot be updated or changed during playback.Flash movies also seem to play more smoothly at higher frame rates when played within a Director projector.
  • Similar scripting environments: Both Flash and Director use a form of Dots notation for their scripting languages. Flash ActionScript resembles JavaScript much more closely than Director Lingo does. Director Lingo uses a different model of command and event control than Flash 5 does. Flash and Director intermovie activity is a two-way street: You can send events from Flash to Director (via Lingo), or you can control Flash movie playback from Director (via Lingo). Just as Flash Movie Clips can be self-contained interactive modules within one overall .SWF file, Flash .SWF files can be components of a much larger and media rich Director movie. To get you started with Director-Flash interactivity, the next section shows you how to send events from Flash movies to Director movies.

Creating Director-specific actions in Flash
You can use Flash .SWF files in any number of ways with Director. If you simply want to use a Flash animation for graphic content within a Director presentation, you can simply use the same .SWF you generated for the Web. Use the Flash Asset Xtra import box (see the more in-depth discussion later in this section) to set the parameters of playback without needing any Lingo. However, if you want Flash actions (in frames or on buttons) to do something in your Director movies, then you need to know how to get Lingo’s attention. The drawback to this type of “dual” interactivity is that you need to plan ahead with both your Flash and Director movies. As with any project, you should outline a storyboard before embarking on a task such as this.

You have three methods to use within the Flash authoring environment, all involving the getURL action. You can assign any of these methods the same way you would with any other Flash interactivity attach these actions to buttons, frames, or ActionScript conditions.

Standard GetURL command
On a Flash Button or frame, open the Actions Panel and assign a getURL action. This is the preferred method of sending information to Director movies because you can deal with the result of the action in Director you do not need to specify what Director does with the string from Flash. When a Button instance is selected and the Actions Panel is in Normal Mode, Flash 5 automatically creates a default on (release) action to contain the getURL action. In the URL setting, create a string to be passed to an event handler in Lingo.A getURL action is assigned to a frame in Flash. The string ProjectOne is entered in the URL text field. This string, in turn, is received by Lingo.

In Director, you need to attach a behavior script to the Flash Sprite so that the getURL action and string can be received by Lingo.The string ProjectOne was assigned to getURL. In Director, we could tell Lingo to go to the frame marker called ProjectOne:

You can enter any word or series of characters (that is, a string) in the URL field. This string is then passed to Lingo.

You can enter any word or series of characters (that is, a string) in the URL field. This string is then passed to Lingo.

When the Flash Sprite plays in Director and the getURL action is executed, the ProjectOne value of getURL is passed as the FlashString argument of the Lingo event handler, on getURL. Lingo will direct the playback of the Director movie to the frame marker ProjectOne.

Event: command
You can also specify an event: handler in the URL field of the getURL action. This method is useful if you would like to describe an event that is repeatedly used in Flash, but needs customized settings with each use. For example, if you want to add a mouse click to go to a different Director frame depending on which button was clicked, you could use the following URL in the getURL action:

event: FClick “ProjectOne”

In Director, you then write a behavior that would receive the FClick event:

How is this different from the last example? If you want to have several events in one script that perform different Lingo commands, you need to label each one with a separate event, such as:

In the preceding example, we have two defined Flash events, FClickButton01 and FclickButton02, which do different things. If we had used the standard getURL action, we could only pass the string to one Lingo command.

Lingo: command
The last getURL method of sending events to Lingo is the most direct method of communicating with Director movies. In the URL field, a lingo: handler is used to specify a Lingo statement. This is the most inflexible method of sending events to Director insofar as you cannot do anything in Director to modify or direct the event. For example, if you added the following code to an on (release), getURL button event in Flash:

lingo: quit

Then the Director movie quits (or the Director projector closes) when that button was clicked. With lingo: statements in getURL actions, you do not need to specify any further Lingo in the Director movie, unless you are setting the value of prescripted variable or executing a event described in the Director movie script.

Controlling .SWF files in Director
You can import and use Flash movies (.SWF files) into Director just as you would any other cast member. Director controls Flash movies with the Flash Asset Xtra. This section shows you how to import Flash movies and use them in the Director Score window. You should already be familiar with the Director authoring environment and basic Behavior use.

The Flash Asset Xtra: Importing Flash movies
Since Director 6.5, the Flash Asset Xtra has enabled Flash movies to play within a Director movie. Again, make sure you have Director 8.5 in order to use Flash 5 movies. If you have Director 8.0 or 7.0.2, you’ll need to export your Flash 4 .SWF files from Flash 5. Director 7.0.1 supports Flash 3 or earlier movies. If you have Director 6.5, you need to export your Flash movies as Flash 2 movies.

To import a Flash movie (.SWF file), do the following:

  1. Start a new Director movie (.DIR file) or open an existing movie.
  2. Use the File➪Import command (Command+R or Ctrl+R) to select a Flash movie (.SWF file). Double-click the file name in the upper portion of the Import dialog , or select the file name and choose Add. You can select several files of different types and import them all at once. When you are done adding files, click Import to bring the Flash movie(s) into the Internal Cast.
  3. You can import several files at once with the Import command. (The Mac version is shown here.)

    You can import several files at once with the Import command. (The Mac version is shown here.)

  4. Open the Cast window (Command+3 or Ctrl+3). Double-click the Flash movie that was imported. This brings up the Flash Asset Properties dialog . The top section of the dialog is used to link to external or remote Flash movies (see following tip and sidebar), while the lower section sets the playback attributes:

The Flash Asset Properties dialog enables you to specify how the Flash movie functions in the Director movie.

The Flash Asset Properties dialog enables you to specify how the Flash movie functions in the Director movie.

  • Media: This setting has two options, Linked and Preload. If you don’t want to store a Flash movie within the Director movie, check Link and specify the path to the Flash movie. Unless you want to link to a Flash movie on the Internet, you should store the Flash movie in the Director movie Flash movies are usually very small due to their vector structure.
  • If Link is checked, then you can also enable Preload. Preloading will force Director to load (or download) the entire .SWF file before it starts playing the Flash movie. Otherwise, Director will start playing the Flash movie as soon as it starts to stream the Flash cast member. See the sidebar at the end of this section for more information on linked Internet files.

  • Playback: This setting has five options that control how Director displays the Flash movie. The Image option, checked by default, determines whether Director shows the graphic content of a Flash movie. The Sound option determines whether Director plays the audio content of a Flash movie.
  • The Direct to Stage option tells Director to give priority to the Flash movie Sprite over all other Sprites currently on the Stage. Although this option may enable Flash movies to playback more smoothly, Director ignores any ink effects applied to the Sprite, and the Flash movie always displays on top of other Sprites.

    The Paused option is akin to adding a stop() Flash action to the first frame of the Flash movie you can force Director to display the movie in a paused state. The Loop option enables continuous playback of the Flash movie. If this option is checked, the Flash movie repeats as soon as it reaches the last frame unless the last frame has a stop() Flash action. It continues to repeat while the Flash Sprite is present in the Director Score, or until it is paused by a Lingo command.

  • Quality: This setting has a drop-down menu with the exact same settings as the Quality setting in the Flash 5 Publish Settings. By default, this setting is High.
  • Scale Mode: By default, this setting uses Auto-Size, which enables Director to automatically resize the Flash movie’s width and height according to the Sprite’s bounding box on the Director stage. Meaning, if you resize the Sprite, then the Flash movie should fit the size of the Sprite box. Auto-Size automatically sets the Scale setting to 100 percent. Conversely, No Scale keeps the Flash movie at the size specified by the Scale setting (covered in a moment) and any subsequent resizing of the Sprite bounding box may crop the Flash movie. The remaining options, Show All, No Border, and Exact Fit operate the same as the Publish Settings options in Flash 5.
  • Rate: Perhaps one of the most powerful settings in the Flash Asset Properties dialog, Rate controls how fast or slow the Flash movie plays in a Director Scores irrespective of the Tempo setting used in the Score. The Flash Asset Properties’ Rate setting has two options: a dropdown menu and an fps text field. If Normal or Lock-Step is selected, then the fps text field is disabled. Normal plays the Flash movie at its native frame rate, as set in the Flash application via the Modify➪Movie dialog.
  • Lock-Step plays one Flash movie frame for every Director frame that its Sprite occupies (for example, if the Flash movie occupies four frames of the Director score, then only the first four frames of the animation plays back in Director). Therefore, Lock-Step inherits the frame rate of the Director movie as established in the Tempo setting in the Score. Fixed rate enables you to specify a new frame rate for the Flash movie, independent of the original frame rate specified in Flash 5 (via Modify➪ Movie) or the Director Tempo setting in the Score.

  • Scale: This setting works hand-in-hand with the Scale Mode setting. If anything other than Auto-Size is selected in Scale Mode, you can specify what percentage of the original Flash movie is used for the Flash Sprite.
  • If 50 percent is used for the Scale of a 550 × 400 Flash movie and Exact Fit is chosen in Scale Mode, then the movie displays at 225 × 200 in the original placed Flash Sprite on the Stage. If you resize the Sprite box, then it continues to maintain a 50 percent portion of the Sprite box area. After specifying the settings you wish to use for your Flash movie, you can then place the Flash cast member as a Sprite on to the Director Stage.

Using Director’s Property Inspector
Director 8.0 introduced a new look-and-feel to the authoring environment. In addition to a resizable Stage window, you can change the Cast window to view by list or thumbnail, and you can quickly modify Sprite, Cast Member, and Movie attributes (among others) with the Property Inspector.

The Property Inspector enables you to quickly change all of the Flash Asset Properties for any Flash Cast Member. You can click the More Options button on the Property Inspector to access the traditional Flash Asset Properties dialog, which enables you to change Import (for example, path to remotely or locally linked .SWF files) and Media (Linked and Preload) properties.You cannot preview Flash movies in the Property Inspector.

Director’s new Property Inspector

Director’s new Property Inspector

Flash Movies as Sprites
In Director, any item that is used in a movie becomes part of a Cast, and is referred to as a Cast Member. When a Cast Member is placed on the Stage, it becomes a Sprite. A Sprite is an instance of the Cast Member used in the Score. The relationship between a Flash Symbol and a Symbol instance is similar to the relationship between a Director Cast Member and its Sprite(s).

To place a Flash Cast Member on the Director Stage, simply click and drag its Cast Member icon (or thumbnail) from the Internal Cast window to the Stage or the Score. If you drag a Cast Member to the Stage , it automatically becomes a Sprite on the first Sprite channel. If you drag a Sprite to the Score , it is automatically centered on the Stage.

(A) A Flash Sprite on the Director stage. (B) A Flash Sprite in the Director score.

(A) A Flash Sprite on the Director stage. (B) A Flash Sprite in the Director score.

Although Flash Sprites perform almost the same as other Director Sprites, you should be aware of certain Sprite properties before proceeding with Lingo Behaviors and Flash Sprites. For more information on basic animation features of Director, please consult the Using Director 8 manual that comes with the Director software.

  • Sprite Duration: Every Sprite has a duration in the Score. By default, every Sprite dragged to the Score or Stage has a duration of 28 frames. Like digital video and sound Sprites, Flash Sprites only play for as long as their frame duration allows them. For example, if a Flash movie that is 30 Flash frames long (and has a Lock-Step rate) is inserted as a 15-frame Flash Sprite in Director, then Director only shows the first half of the Flash movie.
  • Sprite Inks: Of all the inks available to Sprites, only Copy, Transparent, and Background Transparent have any noticeable effect on Flash Sprites. Copy makes the Flash movie background opaque, in the same color that you specified in the Flash authoring environment. Transparent or Background Transparent hide the background of a Flash movie, so that the Director movie background (and other Director Sprites) show through.
  • With an ink effect of Background Transparent, the white background of the crosshairsButton Flash Sprite drops out.

    With an ink effect of Background Transparent, the white background of the crosshairsButton Flash Sprite drops out.

Controlling .SWF files with Lingo
Not only can you send events from Flash movies to Director movies, but you can also control Flash movies from Director with Lingo. More than 70 Lingo commands exist that are specific for Flash movie assets in a Director movie. Unfortunately, it is beyond the scope of this book to explore so many different commands. This section provides an overview of the new Lingo commands for Flash movie, and shows you how to alter the size and rotation of Flash Sprites.

Lingo and ActionScript
For a complete listing of Flash-specific Lingo commands that can be used with Flash Cast Members and Sprites, access the Help➪Lingo Dictionary in Director 8.5 and search for Flash. Some of the more powerful Lingo commands are getVariable and setVariable, which give you access to any variables inside a Flash 4 or 5 movie. Make sure that you specify the variable name as a string in Director Lingo (unless it’s also the name of a Lingo variable), as in:

on beginSprite me sprite(me.spriteNum).setVariable(“/globals:currentURL”,¬“http://www.theMakers.com”)end

This Lingo code will give the variable currentURL in the globals Movie Clip of the current Sprite (me.spriteNum) the value of http://www.theMakers.com. Therefore, you can use Slashes notation to access nested variables in Movie Clip instances. Similarly, the getFlashProperty and setFlashProperty Lingo commands can use Slashes notation to access Movie Clip or Main Timeline properties:

This Lingo code will retrieve the current X scale of the _root.dog_1 Movie Clip instance and make it the value of a global Director variable named dog_ScaleX. Table below details the Flash Movie Clip and Main Timeline properties that can be retrieved and set by Lingo.

Lingo and actionscript property conversion chart

Lingo and actionscript property conversion chartLingo and actionscript property conversion chart

Macromedia has expanded the Lingo hitTest command (which can be used to detect whether an arbitrary point in the Flash movie is the transparent background area, a normal “fill” area, or a Flash button) to include an #editTest return value to detect Flash 4 and 5 editable text fields. The Lingo hitTest method works much like the hitTest ActionScript method. For more information on Director’s hitTest method, refer to the Help➪Lingo Dictionary. Finally, Director 8.5 adds five new Lingo commands to work with Flash movies:

  • call: This command works just like the call(frame) action in Flash 5. It executes the actions on the specified Flash timeline keyframe.
  • print and printAsBitmap: These commands print the contents of a target Flash timeline.
  • sendXML: This is a new event handler in Director 8.5 that catches any sendXML events from a Flash 5 movie. You can define an on sendXML handler on a Flash Sprite that will execute whenever a sendXML action is executed in the Flash movie.
  • tellTarget and endTellTarget: These commands work like the Flash 4 equivalent actions. However, in Lingo, you nest the actions in a slightly different manner. Also, you can only use the following actions within a tellTarget Lingo group: stop, play, gotoFrame, call(frame), find(label), getFlash Property, and setFlashProperty. You use a tellTarget Lingo action in the following way:
  • This Lingo code targets the nestedMovie Movie Clip instance located on the Main Timeline and sets its scale to 200 percent and moves its playhead to frame 2. Then, Director’s Score moves to frame 5.

Changing the size and rotation of Flash Sprites
The previous section listed the properties of internal Flash Movie Clips that can be manipulated with Lingo. You can also control the Flash Sprite properties with Lingo, which will affect everything in the Flash movie. With the crossButton.swf example used earlier, we can rotate and zoom the Flash movie in Director. Because the crossButton Sprite is a Flash button that already plays a 3D rotation sequence, we disable the Flash button by using a Lingo script in the first frame of the score:

The sprite(1) line of code refers to the Sprite occupying the first Sprite channel, which in our example is the crosshairs_button Flash Sprite. Adding the .buttonsEnabled property lets Director know what property we want to change with the Sprite in this case, Flash button activity. Setting this property to false means it is being turned off. Next, add the following behavior script to the Flash Sprite:

This Behavior causes the Flash Sprite to rotate a full 720 degrees two revolutions when the mouse enters the Flash Sprite. Here, the .rotation property is called and manipulated. Notice that when the mouse leaves the Sprite, the rotation is reset to 0.

To change this to a zooming behavior, simply change the script to the following:

For a cool effect, reenable the Flash button by removing the on enterFrame section, containing the sprite(1).buttonsEnabled line, from the frame 1 script. Now, as the Flash movie zooms, the button continues to rotate on a 3D axis. To view the current Flash Sprite properties in Director’s Message window, you can add the following line of Lingo to the Frame Script:

Then, on frame 2, create the following Frame Script:

The showProps() command shows you the current properties of the Flash Sprite and Cast Member, as shown below.

Director’s Message window, displaying the current Flash Sprite properties

Director’s Message window, displaying the current Flash Sprite properties



Face Book Twitter Google Plus Instagram Youtube Linkedin Myspace Pinterest Soundcloud Wikipedia

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Flash Topics