Monday, February 11, 2008

SWFObject not working

Please ensure that the div in which the flash embed object will be written to is defined before the inclusion of the external javascript file that defines the SWFObject

Otherwise, it will not be able to write to a div tag that does not yet exist.

Example:

...

<div id="flash_videoplayer"><strong>You need to upgrade your
Flash Player</strong> This is replaced by the Flash content. Place your alternate
content here and users without the Flash plugin or with Javascript
turned off will see this. Content here allows you to leave out <code>noscript</code>
tags. Include a link to <a href="swfobject.html?detectflash=false">bypass the detection</a> if you wish.</div>

...

<script type="text/javascript" src="js/flvplayer_2.js">

==========
The above flvplayer_2.js file contains the code below:

var swfObject = new SWFObject("FlvPlayer2.swf", "flvPlayer2", flv_width, flv_height, "9");
swfObject.addParam("allowScriptAccess", "always");
swfObject.addParam("allowFullScreen", "true");
swfObject.addParam("salign", "tl");
swfObject.addParam("menu", "false");
swfObject.addParam("wmode", "transparent");
swfObject.write("flash_videoplayer");

1 comment:

Anonymous said...

you shoul use "addVariable" for variables and "addParam" for params