OBJECT and EMBED Tags


<OBJECT> and <EMBED> Tags

Technically, you don't need to use HTML to display your Flash file, but if you don't, the SWF file will scale to fit the height of the browser window. If you want to control the appearance of your movie, use HTML to do it.

The <OBJECT> tag, which is used by Internet Explorer on Windows, uses an ActiveX control to play Flash content. The <EMBED> tag, which is used by Internet Explorer on Macintosh and Netscape on both Macintosh and Windows platforms, uses the Netscape plug-in technology to display Flash content. For you as a developer, this means that you need to have both tags sets on your page to make sure that your movie plays. It's important to nest the <EMBED> tag within the <OBJECT> tag. ActiveX-enabled browsers will ignore the <EMBED> tag inside the <OBJECT> tag. Browsers using Netscape's Flash plug-in technology will ignore the <OBJECT> tag and will read only the <EMBED> tag.

You can write the HTML to embed the Flash movie manually, or you can use Flash's Publish feature, which will automatically create HTML that contains both the <OBJECT> and <EMBED> tags. Alternately, you can use Dreamweaver/UltraDev to add your Flash object.

The <OBJECT> tag requires these attributes and parameters:

  • WIDTH and HEIGHT. The width and height of the Flash movie can be expressed either in pixels or as a percentage. Syntax: <OBJECT WIDTH=550, HEIGHT=440>.

  • MOVIE. The URL of the movie you are loading. Syntax: <PARAM NAME =movie VALUE="yourMovie.swf">.

  • CLASSID. The identifier of the ActiveX control that plays Flash movies. Syntax: <OBJECT classid=" clsid :D27CDB6E-AE6D-11cf-96B8-444553540000">.

  • CODEBASE . The URL that tells the browser where to find the Flash Player ActiveX control so that the browser can automatically download it if it's not already installed. Syntax: <OBJECT codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0"> .

The required <EMBED> tag attributes are listed here:

  • WIDTH and HEIGHT. The same as for the <OBJECT> tag. Syntax: <EMBED WIDTH=550, HEIGHT=440>.

  • SRC. The URL of the movie you are loading. Syntax: <EMBED src="yourMovie.swf">.

  • PLUGINSPAGE. The URL that tells the browser where to find the Flash Player plug-in so that the user can download it manually if it is not already installed. Syntax: <EMBED PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"> .

You also can use a series of optional attributes and parameters with the <OBJECT> and <EMBED> tags. These are implemented as parameters in the <OBJECT> tag and as attributes of the <EMBED> tag. The ones that you'll use most often are these:

  • ID. (OBJECT only.) This assigns an identifier to the Flash movie so that it can be referenced using a scripting language such as JavaScript or VBScript. Syntax: <OBJECT ID="thisMovie">.

  • NAME. (EMBED only.) This assigns an identifier to the Flash movie so that it can be referenced using a scripting language such as JavaScript or VBScript. Syntax: <EMBED NAME="thisMovie">.

  • TYPE. (EMBED only.) This specifies the MIME type that lets the browser know which plug-in to use. Syntax: <EMBED type="application/x-shockwave-flash"> .

  • SWLIVECONNECT. This can have a value of true or false. If it is set to true (false is the default value), Flash will start Java as the Player loads. You need this to use FSCommands when you have JavaScript and a Flash movie on the same page.

  • BASE. Relative URLs do not work consistently in all browsers with Flash movies when all of your files are not in the same directory. You enter your base URL in this parameter.

  • PLAY. If you don't want your movie to begin playing as soon as it loads, you need to set this to false. It defaults to true. You'll most likely control this from within your Flash movie.

  • LOOP. Again, you can set your movie to loop continuously or not with this parameter/attribute, but it makes more sense to control looping inside of your movie. It can be either true or false.

  • QUALITY. You can control the quality of the playback of your movie. You're usually going to want to have this set to Best, which anti-aliases everything and smoothes the bitmaps. The other end of the scale is Low, which does not antialias or smooth the bitmaps. Other possible values are AutoLow, AutoHigh, Medium, and High.

  • BGCOLOR . This overrides the background color of your Flash movie, not the HTML page.

  • SCALE. You'll most likely leave this at its default setting of Show All, which maintains the aspect ratio of your movie. Exact Fit can cause distortion because it does not retain the aspect ratio.

  • MENU. This can be true or false. True displays the full menu on right- or Control-click. False shows only the About Flash option.

To see an example of this code in action, check Listing 26.2. This sample has been formatted for easy viewing. This example shows the HTML created by Flash during publishing. Notice that the <EMBED> tag is nested inside the <OBJECT> tag.

Listing 26.2 The Code for Embedding a Flash Movie in an HTML File
 <OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"  codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/  swflash.cab#version=5,0,0,0"  WIDTH=550  HEIGHT=400>      <PARAM NAME=movie VALUE="myMovie.swf">      <PARAM NAME=quality VALUE=high>      <PARAM NAME=bgcolor VALUE=#FFFFFF>      <EMBED src="myMovie.swf"          quality=high          bgcolor=#FFFFFF          WIDTH=550          HEIGHT=400          TYPE="application/x-shockwave-flash"          PLUGINSPAGE="http://www.macromedia.com/shockwave/download/          index.cgi? P1_Prod_Version=ShockwaveFlash">      </EMBED>  </OBJECT> 

So now you have your Flash movie neatly embedded in your HTML page. All your troubles are over, right? Well, not exactly. Now you have to worry about the other differences between the browsers.

Netscape Idiosyncrasies

Netscape 6 has been completely rewritten from previous versions. In fact, Netscape 6 is now vying for the position of the browser most hated by Flash developers. Macromedia and Netscape are working to resolve the following known issues in Netscape 6:

  • Sending JavaScript commands with FSCommand actions will not work, nor will attempts to control the Flash Player with JavaScript methods . This is because LiveConnect is not part of Netscape 6 browser. There is a rumor going around that LiveConnect will be back in release 6.2 of the browser, but I can't confirm that.

  • Using the Backspace key when an input text field is active returns the user to the previous page rather than deleting a character.

  • On a Macintosh, the browser does not allow entry of text into input text fields.

Some versions of Netscape cannot display a Flash movie if the filename contains a space. Spaces in filenames can also cause problems with getURL() and loadMovie() actions in Netscape. You should use the underscore (_) instead of spaces for these and other reasons.

Internet Explorer 4.5 for the Macintosh

Quite possibly the most evil browser in existence is Internet Explorer 4.5 for the Macintosh. You must address a number of unique issues if you are developing for older versions of Internet Explorer on the Macintosh platform. Most of these issues have been fixed in Internet Explorer 5.0 for the Macintosh:

  • You cannot use scripting languages to communicate with Flash movies in Internet Explorer 5.0 or below on a Macintosh.

  • Macintosh Internet Explorer 4.5 will not allow a JavaScript function to be called with a getURL() action. This is fixed in version 5.0 and above, however.

  • Internet Explorer versions 4.5 and below on the Macintosh do not support VBScript at all. If 4.5 does encounter VBScript, a pop-up dialog box will indicate that the browser doesn't understand something on the page.

  • On some systems, it is not possible to view local content using Internet Explorer on the Macintosh. In this case, you can play Flash content through Microsoft Personal Web Server or any other Web server.

  • It is not possible to detect plug-ins with scripting in Internet Explorer 4.5 and below on the Macintosh platform. If you attempt to check for the Flash Player using JavaScript, it will always return a value of false. Internet Explorer version 5.0 supports the plug-in array object that is necessary for detecting Flash.

You could redirect users with Internet Explorer 4.5 on a Macintosh to a page without Flash or to a page with a movie but without browser detection. This involves creating a small Flash movie that asks users if they can properly see it playing. If they can, the browser has the proper Flash Player installed. You should also provide a link on this page for users to download the Flash Player if they can't see the test movie.

You could also redirect users before the page loads if they are using Internet Explorer on a Macintosh by adding the following in the <HEAD> tag:

 <SCRIPT LANGUAGE="JavaScript">  <!--       var myURL = "mac_ie_alternative.html"; if (navigator.        appName == "Microsoft Internet Explorer" &&        navigator.appVersion.indexOf("Mac") != -1 ) {             location = myURL;        }  //-->  </SCRIPT> 

Remember, you'll need to change the value of myURL to be the alternate page for users of Internet Explorer on a Macintosh.

Internet Explorer 5.5 Integration

Internet Explorer 5.5 has new behaviors and a new rendering interface that works with Flash 5. These behaviors enable the browser to access the ActionScript Object model of the Flash 5 player. The new rendering interface allows Flash content to be attached as an element rather than as a traditional object with an <OBJECT> tag.

These behaviors allow the document to directly interact with and control the properties of the Flash movie and its movie clips to do the following dynamically:

  • To change the properties of a movie such as its height, width, quality setting, and background color, or to set whether Flash's right-click context menu is active

  • To change the properties of any movie clip being displayed in the Flash Player, such as its rotation, scale, and Alpha setting, and to determine whether it's playing or stopped

  • To access any of the predefined methods of a movie clip, such as duplicateMovieClip(), startDrag(), gotoAndPlay(), and swapDepths()

The Rendering Interface allows the document to render Flash content as an attached element. Its properties can be accessed and modified to do such actions as the following:

  • To display a Flash movie on top of or underneath a layer of HTML

  • To define a Flash movie as an element of the HTML document in the <HEAD> tag, and then attach it to the document dynamically with all its associated properties

You need to be aware of one final issue. Even the standalone player isn't completely issue-free. And, of course, its problem starts when it needs to open a browser window.

Netscape, Explorer, and Standalone Players

A standalone player is also called a projector. When a standalone projector is running on Windows and you use the getURL() function to open a Web page, the page always opens in Internet Explorer. The page opens in Explorer even if Netscape is chosen as the default browser. If the user doesn't have Internet Explorer, the Web page will not be displayed. Currently, there is no reliable workaround for this problem. Although this might be annoying, for the most part, it's not catastrophic because the vast majority of computers do have IE installed.

Refer to TechNote 14486 on Macromedia's Web site to see if a solution has been found.



Inside Flash
Inside Flash MX (2nd Edition) (Inside (New Riders))
ISBN: 0735712549
EAN: 2147483647
Year: 2005
Pages: 257
Authors: Jody Keating

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net