Home  Client Side Scripting  SWFObject

“SWFObject job test questions and answers guide. The one who provides the best answers with a perfect presentation is the one who wins the job hunting race. Learn SWFObject and get preparation for the new job”

29 SWFObject Questions And Answers

1⟩ Why do we see a dotted border around my SWF when using Firefox 3 on Windows and wmode transparent or opaque?

Firefox 3 on Windows using wmode transparent or opaque introduces a new default style for the object element; it treats it like an active link.

This Firefox implementation deviates from Firefox 3 on Mac, previous Firefox versions on Windows and the default style for the embed element, so it is therefore likely to be a Firefox bug.

The following style rule in the head of your web page should solve this issue:

<style type="text/css" media="screen">

object { outline:none; }



3⟩ Tell me Do SWFs embedded with SWFObject 2 display in the Sony PS3 or Nintendo Wii web browsers?

The Opera web browser on Nintendo Wii displays both Flash content embedded with static and dynamic publishing. Please note that the Wii currently only supports Flash Player 7 content and that Adobe Express Install is not supported.

The Netfront browser on Sony PSP and older versions of PS3 will only display Flash content when using static publishing. The reason for this is that it's JavaScript support is extremely limited, so that the SWFObject 2 script will never be executed. Please also note that it currently only supports Flash Player 6 content and that Adobe Express Install is not supported.


4⟩ Tell me why can not I see Flash content in Firefox 3?

Do you have the Adblock extension installed? In Firefox 3 Adblock incorrectly blocks Flash content (the object tag only, so that's why content embedded with SWFObject 1.5 does work, because it uses the embed tag), even if your entire page is whitelisted. In this case just disable Flash block (by disabling the extension, don't use Adblock's disable feature, because then it still won't show Flash content). Please note that the development of and support for Adblock has been discontinued.


5⟩ How to pass URIs or HTML code as a value using flashvars?

Special characters and the symbols = and & cannot directly be used inside flashvars values (the latter because they are used to stack the flashvars themselves).

You can workaround this issue by escaping these characters before passing them as flashvar values. An example:

encodeURIComponent("&trade") will become %26trade

The values will be available in your swf already unencoded, so no unescaping is needed inside your swf.

Note that encodeURIComponent is not available in all browsers, but is available in all of the common modern versions. If you need full backwards compatibility, you can use escape() instead, but note that escape() does not work well with double-byte characters (like Chinese).

You can also escape these characters manually by using:

%3D instead of =

%26 instead of &


6⟩ How to avoid that extra whitespace is created underneath my SWF?

When using dynamic publishing and a strict HTML DOCTYPE Firefox, Safari and Opera may create a few pixels whitespace underneath your Flash movie.

To avoid this make sure that your object element is set as a block level element, which can be achieved with the following CSS style rule:

<style type="text/css" media="screen">

object { display:block; }



7⟩ How to avoid Active Server Pages error ASP 0139 when using static publishing and Microsoft IIS?

Microsoft IIS's ASP interpreter incorrectly doesn't allow a page with nested <object> tags, resulting in the following error message:

Active Server Pages error 'ASP 0139'

Nested Object

/yourWebpage.html, line XX

An object tag cannot be placed inside another object tag.

You can avoid this error by using one of the following workarounds (note: which workaround will be best will depend on your specific situation):

Configure IIS not to serve .htm and .html files as ASP

Use a server-side include

Create the object tags dynamically, the 'Update - The Dynamic Approach'


8⟩ How to prevent Internet Explorer from showing an error message when using External Interface and SWF that is inside a <form> tag?

This technote provides additional info and two solutions.

It is preferred to use the first solution that applied to SWFObject 2 embedding looks like the following:

function fixReference() {

window["mySwfId"] = document.forms[0]["mySwfId"];




9⟩ Can you please explain how to fix a "Line 56 Out of Memory" error, when unloading a page in Internet Explorer using earlier versions of Flash Player 9 and multiple SWFs using ExternalInterface?

This issue was introduced with the release of Flash Player 9, and is fixed in recent versions of Flash Player 9. You can fix it for the earlier versions by adding the following JavaScript code in the head of your (X)HTML page:

<!--[if IE]>

<script type="text/javascript">

function fixOutOfMemoryError() {

__flash_unloadHandler = function() {};

__flash_savedUnloadHandler = function() {};


window.attachEvent("onbeforeunload", fixOutOfMemoryError);




10⟩ Do you know why does not fscommand work in Internet Explorer with dynamic publishing?

A In order to make fscommand work in Internet Explorer Adobe recommends to add a block of VBScript to capture and forward the FSCommand calls to JavaScript. However VBScript doesn't work anymore when a Flash movie is inserted using innerHTML or outerHTML, as SWFObject's dynamic publishing method does.

Fortunately you can also use JavaScript instead of VBScript to catch the fscommand calls. A small downside is that it uses proprietary attributes (which, again, wrapped in conditional comments will keep your code valid). E.g. the following block of VBScript code:


on error resume next

Sub myCom_FSCommand(ByVal command, ByVal args)

call myCom_DoFSCommand(command, args)

end sub


Can be replaced with:

<!--[if IE]>

<script type="text/javascript" event="FSCommand(command,args)" for="myCom">

myCom_DoFSCommand(command, args);




11⟩ Tell me how to prevent Internet Explorer from crashing and showing an "Operation Aborted" error when a <base> tag is defined?

Including a closing </base> tag will prevent this bug in Internet Explorer being triggered. Because for HTML 4 compliant pages (a closing base tag is forbidden under HTML 4), you could use Internet Explorer conditional comments to keep your HTML valid and still include a closing base tag for HTML 4 documents:

<base href="http://www.yourdomain.com/"><!--[if IE]></base><![endif]-->


12⟩ Tell me why do not I see Flash content in Internet Explorer on Windows while I do have the required minimal Flash Player version installed?

When an install gets corrupted (very often caused by corrupt installers) it is impossible to read the Flash Player version number externally using scripting languages. When using dynamic publishing this results in the display of alternative content, with static publishing we let the object element do its job (it decides whether to show Flash content or alternative content based on its built-in MIME type mechanism) which results in the display of Flash content.


13⟩ How to create a SWF that will encompass 100% of the browser window?

The following technique is also known as Full Browser Flash:

Set both the width and height of your SWF to 100% in your SWFObject definition

Include CSS to get rid of any default margins/padding and set the height of the html element, the body element and the entire chain of block level HTML elements that your SWF will be nested in to 100%, because Firefox (or: any Gecko based browser) in standards compliant mode (or: using a valid DOCTYPE) interprets percentages in a very strict way (to be precise: the percentage of the height of its parent container, which has to be set explicitly):

<style type="text/css" media="screen">

html, body, #containerA, #containerB { height:100%; }

body { margin:0; padding:0; overflow:hidden; }


Manage the scaling and alignment of your SWF and the positioning of your SWF's elements, within your ActionScript code, e.g.:

stage.scaleMode = StageScaleMode.NO_SCALE;

stage.align = StageAlign.TOP_LEFT;

stage.addEventListener(Event.RESIZE, resizeHandler);

function resizeHandler(event:Event):void {

// center stuff



14⟩ What is SWFAddress?

SWFAddress is a JavaScript and ActionScript library that allows Flash websites to support deep linking, and can automatically integrate with SWFObject.


15⟩ Please explain why does swfobject.getFlashPlayerVersion() sometimes incorrectly report the installed Flash Player version?

In the past years there have been several occasions where a Flash Player didn't expose the right version number externally - as can be retrieved with JavaScript -, caused by corrupt Flash Player Mac OS X installers, affecting Firefox, Opera and Safari on Mac OS X, and also all JavaScript detection scripts, including SWFObject 2, SWFObject 1.5, UFO and the Adobe Flash Player Detection Kit.

Known erroneous versions are (major.minor.release version):

9.0.47 exposes 9.0.19

8.0.24 exposes 8.0.23

9.0.115 exposes either 9.0.47 or 9.0.64 (Note: only Adobe Express Install installers, affecting Firefox on Mac OS X only)


16⟩ What is SWFFit?

SWFFit (formerly known as FitFlash) is a JavaScript library used to resize Flash movies according to the browser window size, keeping it accessible independent of the screen resolution. SWFFit primarily configures the web browser to display scroll bars when content exceeds the browser window size. It can also be used to dynamically resize the Flash movie size. It is used together with SWFObject.


17⟩ Explain SWFObject Features?

SWFObject also includes a few utility functions within its API to retrieve Flash Player related information, such as checking whether a specific version of Flash Player is installed, and a few DHTML utilities to help work with the DOM. Because of this, the most common reasons Flash Website developers turn to external JavaScript frameworks such as jQuery or Prototype are satisfied internally, giving developers fewer reasons to add additional JavaScript libraries to their website.

The library can also be used to integrate Flash Player Express Install into the webpage, allowing users to install the latest Flash Player without leaving the site, although this requires a browser restart.


18⟩ Explain SWFObject usage?

SWFObject provides a reliable method of embedding Flash content into a webpage by internally handling the various practices that one must follow in order for different web browsers to display Flash content correctly, and isolating them from the web designer. The developer may interface with the library in a standardized manner, the minimum being a single line of JavaScript code. Therefore even inexperienced web designers without knowledge of the ideal HTML code to embed Flash content, can easily insert Flash content into web pages, and have them reliably work for the widest possible audience (excepting those with JavaScript disabled). Flash content inserted using SWFObject will also work on devices that support JavaScript execution (and Flash Player), such as the Wii, PlayStation 3 and Nokia N800, unlike the PlayStation Portable.


19⟩ What is SWFObject?

SWFObject (originally FlashObject) is an open-source JavaScript library used to embed Adobe Flash content onto Web pages, which is supplied as one small JavaScript file. The library can also detect the installed Adobe Flash Player plug-in in all major web browsers, on all major operating systems (OS), and can redirect the visitor to another webpage or show alternate HTML content if the installed plug-in is not suitable.


20⟩ Do you know why does Firefox load my SWF twice?

Firefox 3 has a known issue that sometimes causes a swf to be 'double initialized'. The problem appears to be fixed in their codebase, but has not been released yet. See the following bugs for more details: bug 438830 and bug 445599.

Or, if you have "Disable cache" selected in your Firefox Web Developer Toolbar extension a double load will occur.