Version 1.6Flash Embedding
API Quick Reference
JavaScript is required to use the quick reference
Overview
glow.embed.Flash provides a straightforward mechanism for embedding Flash movies in your page. It takes care of browser differences, checks that the Flash plugin is installed and can verify that the installed Flash plugin version meets the minimum version requirements for your Flash movie.
To embed a movie, create an instance of glow.embed.Flash with the relevant details and call the embed method. When the embed method is called, object or embed tags will be inserted into the specified container element within the page, replacing all existing content of that element.
The details you always have to pass to the glow.embed.Flash constructor are:
- The url for your swf file.
- The element where the movie is to be embedded.
- The minimum plugin version required to play the movie.
In addition, the following optional details can be provided, depending on your requirements:
- Attributes to be specified on the embed or object tag and any parameters that must be passed to the movie.
- Additional information such as an error message to display to the user in case of problems.
Examples
Here's a simple example, note that container-id is the id of a html element in our page and #container-id is a glow selector, used by glow to locate that element.
HTML
<div id="logo_holder"></div>JavaScript
var my_flash = new glow.embed.Flash(
"/staticarchive/0b2f526abe58f6c99ff05077db920652402f9e62.swf", "div#logo_holder", "9",
{ height: "150px", width: "200px"
});
my_flash.embed(); The variable my_flash will then hold a reference to this new instance of the glow.embed.Flash object. To get direct access to the movie itself (for instance if the movie exposes methods JavaScript can call), use the movie property, e.g.
my_flash.movie.pauseMovie();If you just need to embed the movie and have no further need to interact with it via script, there is no need to store the movie reference, of course, just use:
new glow.embed.Flash("/staticarchive/0b2f526abe58f6c99ff05077db920652402f9e62.swf","div#logo_holder", "9").embed();
There are many configuration options available:
var params = { width: "400", height: "250", className: "my-class-name", attributes: { id: "my-id", name: "hey-ho" }, params: { flashVars: { navColour: "red", username: "Frankie" } }
}; new glow.embed.Flash("/staticarchive/0b2f526abe58f6c99ff05077db920652402f9e62.swf", "#logo_holder", "9", params).embed();
Error Handling
By default, if the user does not have the Flash Player installed, or the installed version is older than the version you specified, a message will be displayed in place of the movie, replacing any existing content of the targeted container.
JavaScript
new glow.embed.Flash("/staticarchive/0b2f526abe58f6c99ff05077db920652402f9e62.swf","div#logo_holder", "20").embed(); You can override the default message by setting the message option in the constructor. Use this to specify either simple text or HTML content to be displayed in the event that the Flash movie cannot be played. You can also set message to be a function, in which case it will be run and the return value used as the message.
JavaScript
new glow.embed.Flash(
"/staticarchive/0b2f526abe58f6c99ff05077db920652402f9e62.swf","div#logo_holder", "20", { message: "You need a version 20 (not yet available) to be able to view our stunning 3D logo."
}).embed();