How to embed SWF in a web page

 

Learn how to embed a swf in a webpage and set the flashVar parameters.

1. Using SWF Object

If you don't use the SWF object already, now is the right time. It comes with detailed documentation and you can download it from this page: http://code.google.com/p/swfobject/.

 

2. Using the code Adobe Flash generates:

When publishing a html file in Adobe Flash, it generates a code for you. You can use this code and modify it by setting your desired width, height and also by rewriting the swf file name. This can be tedious to do since there are more then one occurences of this parameters in the code (one for JavaScript function, one for IE and one for Firefox and other browsers.) To made things easier I programmed a PHP function using which you can generate the modified code by ease.

Download the PHP function here: phpfunction.html
You will need also this JS File: AC_RunActiveContent.js

How to use the function:

			
	<?
		$link = '/flash/3d-rotate/images/rotateTool_startpage.swf';
		$path = '/flash/3d-rotate/images/deuter/';
	
	
		$data = Array(
			"id" => "3d-rotate",
			"width" => "500",
			"height" => "375",
			"src" => $link,
			"bgcolor" => "#FFFFFF",
			"flashvars" => "path=".$path
		);
		
		echo getFlashTag($data);
	?>

id is the flash movie id, choose any text you like
width is the movie width
width is the movie height
src is the path to the swf
bgcolor is the bgcolor of the movie
flashvars are the flashvars


If you don't use PHP and want to use the flash generated code, you can download this sample code: adobeflashcode.html. However take a look on how the PHP function is structured to see which parts of the code need to be updated.

 

3. Embedding without JavaScript

If you do not want to use JavaScript, you can use this code to embed a flash movie into a website. You can download the example here: example_htmlPage2.zip.

You can see also how the flashvars are set in the above example - variable "path" is set the value "deuter".

 

4. Joomla Integration

Here you can find an example on Joomla Integration: http://www.yofla.com/joomla/index.php?option=com_content&view=article&id=1:3d-rotate-flexi-embed-test.

 

YoFLA Software

YoFLA Utils