| Building and Deploying Flex 2 Applications > Deploying Flex Applications > Creating a Wrapper > About the <object> and <embed> tags | |||
The <object> and <embed> tags embed your Flex application in the wrapper. They support a set of properties that add additional functionality to the wrapper. These properties let you change the appearance of the SWF file on the page or change some of its properties such as the title or language. If you want to customize your wrapper, you can add these properties to the wrapper.
The <object> tag is used by Internet Explorer 3.0 or later on Windows 9x, Windows 2000, Windows NT, Windows ME, and Windows XP platforms or any browser that supports the use of the Flash ActiveX control. The <embed> tag is used by Netscape Navigator 2.0 or later, or browsers that support the use of the Netscape-compatible plug-in version of Flash Player.
When an ActiveX-enabled browser loads the HTML page, it reads the values set on the <object> and ignores the <embed> tag. When browsers using the Flash plug-in load the HTML page, they read the values set on the <embed> tag and ignore the <object> tag. Make sure that the properties for each tag are identical, unless you want different results depending on the user's browser.
You must set the values of four required properties (height, width, classid, and codebase) as attributes in the <object> tag. All other properties are optional and you set their values in separate, named <param> tags.
The following example shows the required properties as attributes of the <object> tag, and four optional properties, src, play, loop, and quality, as <param> child tags:
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="100" height="100" codebase="http://active.macromedia.com/flash7/cabs/ swflash.cab#version=9,0,0,0">
<param name="src" value="moviename.swf">
<param name="play" value="true">
<param name="loop" value="true">
<param name="quality" value="high">
</object>
Although the src property is technically an optional tag, without it, there is no reference to the application you want the client to load. Therefore, your wrapper should always set the src property in both the <object> and <embed> tags.
For the <embed> tag, all settings are attributes that appear between the angle brackets of the opening <embed> tag. The <embed> tag requires the height and width attributes, and the pluginspage attribute, which is the equivalent of the <object> tag's codebase property. The <embed> tag does not require a classid attribute.
|
TIP |
|
Although the |
The following example shows a simple <embed> tag with the optional quality attribute:
<embed src="moviename.swf" width="100" height="100" quality="high" pluginspage="http://www.macromedia.com/shockwave/
download/index.cgi?P1_Prod_Version=ShockwaveFlash"> </embed>
To use both tags together, position the <embed> tag just before the closing </object> tag, as the following example shows:
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="100" height="100" codebase="http://active.macromedia.com/flash7/cabs/ swflash.cab#version=9,0,0,0">
<param name="src" value="moviename.swf">
<param name="play" value="true">
<param name="loop" value="true">
<param name="quality" value="high">
<embed src="moviename.swf" width="100" height="100" play="true" loop="true" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">
</embed>
</object>
When you define parameters for the <object> tag, also add them as tag properties to the <embed> tag so that the SWF file appears the same on the page regardless of the client's browser.
Not all properties are supported by both the <object> and the <embed> tags. For example, the id property is used only by the <object> tag, just as the name property is used only by the <embed> tag.
In some cases, the <object> and <embed> tag properties duplicate properties that you can set on the <mx:Application> tag in the Flex application source code. For example, you can set the height and width properties of the SWF file on the <object> and <embed> tags or you can set them on the <mx:Application> tag.
The following table describes the supported <object> and <embed> tag properties:
|
Property |
Type |
Description |
|---|---|---|
align
|
String |
Specifies the position of the SWF file. The
|
allowNetworking
|
String |
Restricts browser communication. This property affects more APIs than the The
For more information, see Programming ActionScript 3.0. |
allowScriptAccess
|
String |
Controls the ability to perform outbound scripting from within the SWF file. The Valid values are as follows:
The default value is This property affects the following operations:
For more information, see Programming ActionScript 3.0. |
archive
|
String |
Specifies a space-separated list of URIs for archives containing resources used by the application, which may include the resources specified by the Preloading archives can result in reduced load times for applications. Archives specified as relative URIs are interpreted relative to the |
base
|
String |
Specifies the base directory or URL used to resolve relative path statements in ActionScript. |
bgcolor
|
String |
Specifies the background color of the application. Use this property to override the background color setting specified in the SWF file. This property does not affect the background color of the HTML page. Valid formats for The Application container's style uses an image as the default background image. This image obscures any background color settings that you might make. So, to make the value of the <mx:Style>
Application {
backgroundImage: " ";
}
</mx:Style>
|
border
|
int |
Specifies the width of the SWF file's border, in pixels. The default value for this property depends on the user agent. |
classid
|
String |
Defines the This property is used for the For the |
codebase
|
String |
Identifies the location of Flash Player ActiveX control so that the browser can download it if it is not already installed. This property is used for the You can modify this property by using the settings of the Flex Data Services server or from Flex Builder. For the Like the |
class
Removed per p4 72212, which fixed bugs 82995 and 81617
|
String |
Assigns a class name or set of class names to an element. Any number of elements can be assigned the same class name or names. Multiple class names must be separated by white space characters. The class attribute has several roles in HTML:
A class name may be shared by several element instances. |
|
String |
Defines the content type of data expected when downloading the application specified by the The The default value of the |
data
|
String |
Specifies the location of the application's data; for example, instance image data for objects that define images. If the |
declare
|
Boolean |
Makes the current SWF file's definition a declaration only. The SWF file must be instantiated by a subsequent object definition referring to this declaration. |
devicefont
|
Boolean |
Specifies whether static text objects for which the |
dir
|
String |
Specifies the base direction of text in an element's content and attribute values. It also specifies the directionality of tables. Valid values are |
flashVars
|
String |
Sends variables to the application. The format is a set of name-value pairs, each separated by an ampersand (&). Browsers support string sizes of up to 64 KB (65535 bytes) in length. The default value of this property is an empty string. If you use query string parameters when requesting an MXML file from the Flex Data Services server, Flex converts them to For more information on using |
height
|
int |
Defines the height, in pixels, of the SWF file. Flash Player makes a best guess to determine the height of the application if none is provided. The browser scales an object or image to match the height and width specified by the author. You can set this value to a fixed number or a percentage value; for example, Lengths expressed as percentages are based on the horizontal or vertical space currently available, not on the default size of the SWF file. FireFox browsers do not support percentage-based values. You can also set the height of a Flex application by setting the For the |
hspace
|
int |
Specifies the amount of white space inserted to the left and right of the SWF file. The default value is not specified, but is generally a small, nonzero length. |
id
|
String |
Identifies the SWF file to the host environment (a web browser, for example) so that it can be referenced by using a scripting language such as VBScript or JavaScript. The |
lang
|
String |
Specifies the base language of an element's property values and text content. The default value is |
menu
|
Boolean |
Changes the appearance of the menu that appears when users right-click over a Flex application in Flash Player. Set to The default value is |
name
|
String |
Identifies the SWF file to the host environment (a web browser, typically) so that it can be referenced by using a scripting language. The |
pluginspage
|
String |
Identifies the location of Flash Player plug-in so that the user can download it if it is not already installed. This property is used for the You can modify this property by using the settings of the Flex Data Services server or from Flex Builder. Like the |
quality
|
String |
Defines the quality of playback in Flash Player. Valid values of quality are The The The The The The |
salign
|
String |
Positions the SWF file within the browser. Valid values are
|
scale
|
String |
Defines how the browser fills the screen with the SWF file. The default value is Set to Set to Set to |
src
|
String |
Identifies the location of the SWF file. If you write a custom wrapper but deploy your application as MXML files and not pregenerated SWF files on a Flex Data Services server, use the following naming convention: movie_name.mxml.swf Use this property for the |
standby
|
String |
Defines a message that the browser displays while loading the object's implementation and data. |
style
|
String |
Specifies style information for the SWF file. The syntax of the value of the Styles set with this property do not affect components or the Application container in the Flex application. Rather, they apply to the SWF file as it appears on the HTML page. |
|
|
Boolean |
Determines whether the Netscape-specific Set to |
|
|
int |
Specifies the position of the SWF file in the tabbing order for the current document. This value must be a number between 0 and 32767. User agents should ignore leading zeros. |
title
|
String |
Displays information about the SWF file. Values of the |
type
|
String |
Specifies the content type for the data specified by the The If the value of this property differs from the HTTP Content-Type returned by the server, the HTTP Content-Type takes precedence. |
usemap
|
String |
Associates an image map with the SWF file. The image map is defined by a |
|
|
int |
Specifies the amount of white space inserted above and below the SWF file. The default value is not specified, but is generally a small, nonzero length. |
|
width |
int |
Defines the width, in pixels, of the SWF file. Flash Player makes a best guess to determine the width of the application if none is provided. Browsers scale an You can set this value to a fixed number or a percentage value. For example, "width=100" or "width="50%". Lengths expressed as percentages are based on the horizontal or vertical space currently available, not on the natural size of the SWF file. You can also set the width of a Flex application by setting the For the |
|
|
String |
Sets the Window Mode property of the SWF file for transparency, layering, and positioning in the browser. Valid values of Set to Set to Set to To make sections of your SWF file transparent, you must set the The |
The <object> and <embed> tags can also take additional properties that are not supported by Flex applications. These unsupported properties are listed in Unsupported properties.
Flex 2
RSS feed | Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flex/2/docs/00001590.html
Comments
beingthexemplary said on Oct 10, 2007 at 10:00 AM :