embedFlash Function


Introduction

Since Microsoft has had some problems with the Eolas patent, they decided to change the way that IE handles ActiveX. Therefore anyone that views a webpage with flash embedded, will get a popup to confirm they want view the flash object. From a usability point of view this is not ideal and therefore a solution involving Javascript and an external .js file can bypass this problem. A downside is, that besides flash, you are now also dependant on Javascript. Consider this before deploying the solution, since it can decrease the accessibility of your site.


The Function

embedFlash(source, width, height, flashVersion, protocol, movieID, play, loop, menu, quality, scale, align, wmode, bgColor, base, flashVars, swLiveConnect, extraObjectParams, extraEmbedParams).


Usage

To use the embedFlash function in your own pages, you must first include the "embedFlash.js". This document holds the function. Then you can call the function from any place within the <body> tags. The code below shows you an example of how to use it. Also take a look at "example.htm" as it is included in this zip file.

<html>
<head>
<title></title>
<script type="text/javascript" src="embedFlash.js"></script>
</head>
<body>
<script language="JavaScript" type="text/javascript">
embedFlash('example.swf', '550', '400', '7,0,0,0', 'http', 'myMovie', 'true', 'false', 'false', 'best', 'noborder', 'right', 'opaque', '#CC0000', '', 'myFlashVar=embedFlash', 'false', '', '');
</script>
</body>
</html>


Required parameters:

  • source - Specifies the location (URL) of the movie to be loaded. (e.g. "http://www.mysite.com/mymovie.swf").
  • width - Specifies the width of the movie in either pixels or percentage of browser window. (e.g. "100%")
  • height - Specifies the height of the movie in either pixels or percentage of browser window. (e.g. "100%")
  • flashVersion - The version of flash used (e.g. "7,0,0,0")


Optional parameters and possible values:

  • protocol - Specifies the transfer protocol that the movie is used within (use either "http" or "https"). The default value is "http" if this attribute is omitted. Use "https" in order to avoid a warning while using flash inside an SSL environment.
  • movieID - Identifies the Flash movie to the host environment (a web browser, for example) so that it can be referenced using a scripting language. This sets both the "id" and "name" parameter in the <object> and <embed> tag (e.g. "myMovie")
  • play - ("true"or"false") Specifies whether the movie begins playing immediately on loading in the browser. The default value is true if this attribute is omitted.
  • loop - ("true"or"false") Specifies whether the movie repeats indefinitely or stops when it reaches the last frame. The default value is true if this attribute is omitted.
  • menu - ("true"or"false")
    • True displays the full menu, allowing the user a variety of options to enhance or control playback.
    • False displays a menu that contains only the Settings option and the About Flash option.
  • quality - ("low", "high", "autolow", "autohigh", "best")
    • "low" favors playback speed over appearance and never uses anti-aliasing.
    • "autolow" emphasizes speed at first but improves appearance whenever possible. Playback begins with anti-aliasing turned off. If the Flash Player detects that the processor can handle it, anti-aliasing is turned on.
    • "autohigh" emphasizes playback speed and appearance equally at first but sacrifices appearance for playback speed if necessary. Playback begins with anti-aliasing turned on. If the actual frame rate drops below the specified frame rate, anti-aliasing is turned off to improve playback speed. Use this setting to emulate the View > Antialias setting in Flash.
    • "medium" applies some anti-aliasing and does not smooth bitmaps. It produces a better quality than the Low setting, but lower quality than the High setting.
    • "high" favors appearance over playback speed and always applies anti-aliasing. If the movie does not contain animation, bitmaps are smoothed; if the movie has animation, bitmaps are not smoothed. "High" is used when the quality value is omitted.
    • "best" provides the best display quality and does not consider playback speed. All output is anti-aliased and all bitmaps are smoothed.
  • scale - ("showall", "noborder" or "exactfit")
    • If omitted, the default value is "showall". This makes the entire movie visible in the specified area without distortion, while maintaining the original aspect ratio of the movie. Borders may appear on two sides of the movie.
    • "noborder" scales the movie to fill the specified area, without distortion but possibly with some cropping, while maintaining the original aspect ratio of the movie.
    • exactfit" makes the entire movie visible in the specified area without trying to preserve the original aspect ratio. Distortion may occur.
  • align - ("left", "right", "top" or "bottom")
    • If omitted, the default centers the movie in the browser window and crops edges if the browser window is smaller than the movie.
    • "left", "right, "top", and "bottom" align the movie along the corresponding edge of the browser window and crop the remaining three sides as needed.
  • wmode - ("window", "opaque" or "transparent") Sets the Window Mode property of the Flash movie for transparency, layering, and positioning in the browser. If omitted, the default value is "window".
    • "window" movie plays in its own rectangular window on a web page.
    • "opaque" the movie hides everything on the page behind it.
    • "transparent" the background of the HTML page shows through all transparent portions of the movie, this may slow animation performance.

      Note: This property is not supported in all browsers and platforms. For more information about WMODE see How to make a Flash movie with a transparent background (TechNote tn_14201).
  • bgColor - (#RRGGBB, hexadecimal RGB value) Specifies the background color of the movie. Use this attribute to override the background color setting specified in the Flash file. This attribute does not affect the background color of the HTML page.
  • base - Specifies the base directory or URL used to resolve all relative path statements in the Flash Player movie. This attribute is helpful when your Flash Player movies are kept in a different directory from your other files.
  • flashVars (variable to pass to Flash Player) Requires Macromedia Flash Player 6 or later.
    • Used to send root level variables to the movie. The format of the string is a set of name=value combinations separated by '&'.
    • Browsers will support string sizes of up to 64KB (65535 bytes) in length.
    • For more information on FlashVars, please refer to Using FlashVars to pass variables to a SWF (TechNote tn_16417).
  • swLiveConnect - ("true"or"false") Specifies whether the browser should start Java when loading the Flash Player for the first time. The default value is false if this attribute is omitted. If you use JavaScript and Flash on the same page, Java must be running for the FSCommand to work. The default value is false if this attribute is omitted.
  • extraObjectParams - With this parameter you can add additional lines of code to the object tag. For example to add javascript functions (e.g. onmousewheel()). This code is added at the end of the <object> tag.
  • extraEmbedParams - With this parameter you can add additional lines of code to the embed tag. This code is added at the end of the <embed> tag.
The information used in this document is partly based on: http://www.macromedia.com/go/tn_12701.

If you ran into a bug or problem, please send an email to: public@telamedia.com.