SharePoint, Technical

Use Flash in SharePoint 2010

The idea of using Flash inside SharePoint 2007 is well documented and I’ve even done it a few times myself.  Smile My preferred method (non-code) is to slap a Content Editor web part (CEWP) on the page, go into the HTML editor, and add my <object> code.  Worked like a charm.

Not so much in 2010.  You can add a CEWP to a 2010 page, you can go into the HTML editor and add your <object> code, but the page will never load the swf file.  There are recommendations out there saying to change the Browser File Handling setting for the web application to Permissive from Strict, but this didn’t fix anything for me (tried in three separate environments.)  What did work is the following method using a Page Viewer web part…

  1. Upload your swf file to a library in your site (I prefer Site Assets library if you’re not using publishing features)
  2. Create a HTML file locally with the content:
       1: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

       2: <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

       3: <head>

       4: <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

       5: <title>Flash Page</title>

       6: </head>

       7: <body>

       8: <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="300" height="300" id="&lt;your swf filename here>" align="middle">

       9: <param name="allowScriptAccess" value="sameDomain" />

      10: <param name="movie" value="&lt;your swf filename here>.swf" />

      11: <param name="quality" value="high" />

      12: <param name="bgcolor" value="#ffffff" />

      13: <embed src="http://site/SiteAssets/&amp;amp;lt;your swf filename here>.swf" quality="high" bgcolor="#ffffcc" width="300" height="300" name="<Flash File Name>" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />

      14: </object>

      15: </body>

      16: </html>

    Replace the <your swf filename here> with your filename, and changing any other params you need.

  3. Upload the .html file to your Site Assets library (or wherever you put your .swf file)
  4. To test your progress, click on the .html file in the library.  If you’ve done everything right so far, a page should open in your browser which loads the Flash file (it may prompt you to show the file depending on your browser settings)
  5. Copy the URL of the .html file in it’s new location
  6. Navigate to the page where you want the Flash file to appear and go into edit mode
  7. Add a Page Viewer web part
  8. Edit the Page Viewer web part and choose the Web Page option, entering the link to your .html file in the Link text box
  9. Click OK, and ta-da!
  10. You will want to edit the web part again to set height and width, and hide or change the title, etc.  But that’s up to you.

That’s the only method that worked for me.  I found that the Browser File Handling setting had no impact on whether this method worked or not, so don’t worry about messing with that.

Edit: Turns out the Browser File Handling does need to be set to Permissive.  At least it needs to be Permissive when you upload your HTML file.  You can change it back to Strict after that if you need to.  It looks like SharePoint adds the headers during file upload, not run time.  So if you upload the HTML file with Strict, headers get added that prompt the user to download the file instead of just view it in the browser.