Saturday, June 16, 2012

STEP 1: Create alternative content using standards compliant markup

SWFObject's dynamic embed method follows the principle of progressive enhancement and replaces alternative HTML content for Flash content when enough JavaScript and Flash plug-in support is available. First define your alternative content and label it with an id:

 xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
  
    </span><span class="pln">SWFObject dynamic embed - step 1</span><span class="tag">
     http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  
  
    
     id="myContent">
      Alternative content
    

 


STEP 2: Include the SWFObject JavaScript library in the head of your HTML page

The SWFObject library consists of one external JavaScript file. SWFObject will be executed as soon as it is read and will perform all DOM manipulations as soon as the DOM is loaded - for all browsers that support this, like IE, Firefox, Safari and Opera 9+ - or otherwise as soon as the onload event fires:

 xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
  
    </span><span class="pln">SWFObject dynamic embed - step 2</span><span class="tag">
     http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  
     type="text/javascript" src="swfobject.js">

  
  
     id="myContent">
      Alternative content
    
  

STEP 3: Embed your SWF with JavaScript

swfobject.embedSWF(swfUrl, id, width, height, version, expressInstallSwfurl, flashvars, params, attributes, callbackFn) has five required and five optional arguments:
  1. swfUrl (String, required) specifies the URL of your SWF
  2. id (String, required) specifies the id of the HTML element (containing your alternative content) you would like to have replaced by your Flash content
  3. width (String, required) specifies the width of your SWF
  4. height (String, required) specifies the height of your SWF
  5. version (String, required) specifies the Flash player version your SWF is published for (format is: "major.minor.release" or "major")
  6. expressInstallSwfurl (String, optional) specifies the URL of your express install SWF and activates Adobe express install. Please note that express install will only fire once (the first time that it is invoked), that it is only supported by Flash Player 6.0.65 or higher on Win or Mac platforms, and that it requires a minimal SWF size of 310x137px.
  7. flashvars (Object, optional) specifies your flashvars with name:value pairs
  8. params (Object, optional) specifies your nested object element params with name:value pairs
  9. attributes (Object, optional) specifies your object's attributes with name:value pairs
  10. callbackFn (JavaScript function, optional) can be used to define a callback function that is called on both success or failure of creating a Flash plug-in on the page (see API documentation) NOTE: You can omit the optional parameters, as long as you don't break the parameter order. If you don't want to use an optional parameter, but would like to use a following optional parameter, you can simply pass false as its value. For the flashvars, params and attributes JavaScript Objects, you can also pass an empty object instead: {}.
    
     xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
      
        </span><span class="pln">SWFObject dynamic embed - step 3</span><span class="tag">
         http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
         type="text/javascript" src="swfobject.js">
        
         type="text/javascript">
        swfobject.embedSWF("myContent.swf", "myContent", "300", "120", "9.0.0");
        
    
      
      
         id="myContent">
          Alternative content
        
      
    
     
    Resource: http://code.google.com/p/swfobject/wiki/documentation
     
    Hitachi Corporate Resources