Skip to main content

Flash, HTML pages, and SWFAddress

This is my solution for using Flash, SWFAddress, and HTML fall-back pages. It is more quick and dirty than “the right” solution, but it falls firmly into the “works for me” category.

I use SWFObject (link) to detect and execute a Flash site and to fall back to a non-Flash site when the browser cannot handle Flash

Typically, the code will look like the following:

 <script type="text/javascript" src="./js/swfobject.js"></script>
 <script type="text/javascript">
  var flashvars = {};
  var params = {};
  params.menu = "false";
  params.quality = "best";
  params.allowfullscreen = "false";
  params.wmode ="transparent";
  var attributes = {};
  attributes.align = "TL";
  swfobject.embedSWF("website.swf", "nonflash_content", "100%", "100%", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
 </script>

Extremely straightforward, except when you want to incorporate something like SWFAddress (link).

Say you have multiple pages:

http://www.site.com/index.html
http://www.site.com/media.html
http://www.site.com/contact.html

For the index page you can use the above SWFObject method because you will load the Flash file as your main homepage.

When you want to go directly to the media.html part of the Flash file you can pass a variable to the Flash movie to change the start point of your Flash file. All pretty straightforward. Throw in SWFAddress (link) and you have a way of handling changing the URL of the page while you browse the Flash site.

ie.
http://www.site.com/#/index.html
http://www.site.com/#/media.html
http://www.site.com/#/contact.html

Now, say you want to add a non-Flash representation of media.html. With SWFObject, you can redirect to the correct page, but if you’re using SWFAddress as well, you may run into a problem that manifests as incorrect URLS as SWFAddress handles URL address changes by appending onto the base URL:

http://www.site.com/media.html/#/contact.html

What would be nice is when you go to http://www.site.com/media.html is for the page to be smart enough to detect whether the browser can handle Flash or if it needs to fall back to the HTML page.

Easiest way I found was to just do a windows.location.replace if Flash is detected.

<script type="text/javascript">

   if (swfobject.hasFlashPlayerVersion("9")) {
     window.location.replace("http://www.site.com/#/media.html");
   }

 </script>


So, the logic follows this path:

If Flash capable, then redirect to the main page with the appropriate appended SWFAddress logic (ie. index.html/#/media.html ) which will use the logic of SWFAddress to set the site at the right point in the Flash movie.

Otherwise, it will just ignore the Flash detection and display the HTML page as is.

SWFAddress will be explained in greater detail in another post.

Comments

  1. Great information about hire.I learnt more information about it.I like to know
    through your site.Please update it.

    ReplyDelete

Post a Comment

Popular posts from this blog

How To Run Chrome From Within Notepad++

If you have recently tried to Run  Chrome from within Notepad++ recently, you've probably encountered the same issue I did.  Chrome didn't run. The fix is actually really simple.  Open up the Run box in Notepad++ and browse to your installation of Chrome. ie.  C:\Program Files\Google\Chrome\Application\Chrome.exe Select the file when you find it.  Now, the trick is: Put quotation marks around the path you see in the Run  box.  Now, put 1 space after the closing quotation mark. Type this: $(FULL_CURRENT_PATH) It'll look something like this: Click Run .  If Chrome opens, click Save and set your hotkey.

Developer Note: Virtuemart - Editing the Add to Cart MooTool Popup

To edit the “Add To Cart” popup that appears when you add an item to a cart in Virtuemart, there are few files that you need to know about. These are the files to know \components\com_virtuemart\themes\default\theme.js \components\com_virtuemart\js\mootools\   - contains the files for editing the appearance of the popup. To edit the appearance of the box, edit \components\com_virtuemart\js\mootools\mooPrompt.css to change the styles as well as editing the 2 images in the directory to edit how they appear as well (close box and header-background)

Divi Theme - Remove pause 'on hover' of the full width slider

In the Divi theme, open up /js/custom.js Comment out the following code (around line 144) if ( settings.slideshow && et_slides_number > 1 ) { $et_slider.hover( function() { $et_slider.addClass( 'et_slider_hovered' ); if ( typeof et_slider_timer != 'undefined' ) { clearInterval( et_slider_timer ); } }, function() { $et_slider.removeClass( 'et_slider_hovered' ); et_slider_auto_rotate(); } ); }