01.11.07

Faust: Flash Augmenting Standards

  • Posted by: space150

Wouldn’t it be nice if you could write your site only once, reach 100% of your audience, adhere to web standards, optimize your site for search, AND use Flash?

If you’re willing to make a deal, you can use a process space150 calls Faust: Flash Augmenting Standards.

Every web developer faces the problem sooner or later. The client – or the designer – wants to use interactive animation, video or sound to communicate their ideas. Flash is your best option.

However, Flash is not an open web standard like HTML, CSS and JavaScript. Because of its popularity, Flash is really a “de facto” standard, widely available to many users, but not all.

Should you build two separate sites? One in Flash and one with web-standard HTML? This can be very time consuming. It’s also very hard to keep the content synchronized. Now you have two versions of the content, which can be a problem for search engines.

Many developers build a “hybrid” site: mainly HTML, with some Flash embedded in the page. This works well for video from sites like YouTube and Vimeo.

But what if you want a Flash menu for navigation? Even if 89.1% of your users have Flash, there are still 10.9% who don’t. They won’t be able to browse your site. And that includes your most connected users: search engine web crawlers like GoogleBot who can help people find your site.

Wouldn’t it be nice if you could write the site only once, reach 100% of your audience, adhere to web standards, optimize your site for search, AND use Flash?

If you’re willing to make a deal, you can use a process space150 calls Faust: Flash Augmenting Standards.

Faust is a process for writing accessible sites where the page seen by users with Flash installed uses the same HTML as the page seen by users without Flash. In fact, the Flash movie parses content right out of the HTML page.

Faust in Four Parts

Web Standards are like a delicious layer cake.

  • HTML for structure and content
  • CSS for style
  • JavaScript for behavior

The layered approach is called Progressive Enhancement, and when it’s part of your site’s recipe from the start, you can feed at least some piece of content to any user who visits. This is especially important for search engines. For the most part, search engine web crawlers like GoogleBot are picky eaters. If you don’t give them a taste of HTML, they’ll find a meal elsewhere.

At space150, we add a fourth layer to the cake:

  • Flash, for UI features the browser doesn’t have, and for multimedia (video, animation, sound)

The Faust Process

Here’s the principle: Every element of Flash content should have a corresponding HTML representation.

  • For Flash video, add a still image, text description, and link to the video file
  • For Flash slideshows, add an ordered list with links to the thumbnails and large images
  • for Flash navigation, parse an ordered list of links from the HTML of the page to create the Flash menu

When Flash isn’t available, the user still gets HTML content styled with CSS, and behavior in JavaScript.

We call the entire process Faust, which stands for “Flash Augmenting Standards”. We’ve launched many sites with Faust, and have found it to offer quite a few benefits.

  • Faust is search engine friendly

    Search engines will read and index your content, navigate all levels of your website, score, index and rank your website pages accordingly. There are no tricks involved – a search engine robot will see the same content the user sees.

  • You only need one codebase

    In Faust, content for Flash is a single source of data: the HTML. You don’t need a new XML structure. The same lists, images, and links you display for users without Flash are consumed for users with Flash.

  • It’s easy for your CMS

    Any content management system that outputs valid HTML will work.

  • Add multimedia without compromising basic accessibility

    Although users without the Flash player will not see video or animated content, they will benefit from the alternate content you provide. We don’t claim our sites are perfectly accessible. We are looking to the community for help with Faust, to push it forward, and improve accessibility.

I’m a Developer. How Do I Build A Site With Faust?

The recipe for Faust is simple. Start with a base layer of descriptive HTML. Add CSS to taste. Extend with JavaScript where necessary.

From Geoff Stearns article Using alternate content as content in Flash:

The idea is that you build your pages without Flash, then add in the Flash parts later using Javascript if the user has the correct version of the Flash player.

For the Flash layer, we need two additional scoops of JavaScript:

  • SWFObject.js to detect and embed Flash (UFO would work as well)
  • space150’s innerXHTML.js to collect and pass valid HTML elements into Flash for re-use as XML

Remember, in Faust, every element of Flash content should have a corresponding HTML representation. We’re providing alternative content, and in Faust it’s required—just like an alt attribute is required for images in valid HTML.

For example, let’s say you want to create a Flash slideshow. First, you would add the markup:

<div id="slides">
  <ul class="slides photos">
    <li>
      <a title="The Beach" href="photo1.jpg">
        <img alt="Thumbnail of The Beach" title="Thumbnail of the Beach" 
            src="photo1_t.jpg" />
      </a>
    </li>
    <li>
      <a title="The Sky" href="photo2.jpg">
        <img alt="Thumbnail of the Sky" title="Thumbnail of the Sky" 
            src="photo2_t.jpg" />
      </a>
    </li>
  </ul>
</div>


Now the content is out there for Google, and users without JavaScript and Flash.

Next, we’ll use SWFObject to embed the Flash module. But check out the third line:

<script type="text/javascript">
  var so = new SWFObject("slideshow.swf", "slideshow", "580", "445", "7", "#ffffff");
  so.addVariable("strXML", innerXHTML("slides"));
  so.write("slides");
</script>


space150’s innerXHTML parses the HTML right out of the slides div, passing it to Flash as the variable strXML.

You may be familiar with innerHTML, which returns the HTML inside an element. Unfortunately, the browsers’ internal representations of HTML documents vary widely. Internet Explorer’s version is characteristically egregious:

<UL class="slides photos">
<LI><A title="The Beach" href="photo1.jpg">
<IMG title="Thumbnail of the Beach" alt="Thumbnail of The Beach" src="photo1_t.jpg">
 </A>
<LI><A title="The Sky" href="photo2.jpg">
<IMG title="Thumbnail of the Sky" alt="Thumbnail of the Sky" src="photo2_t.jpg">
 </A></LI></UL>

Yikes! Why are all the element names capitalized? Where did the closing tags go? Firefox and Safari were (much) better, but still inconsistent.

So, we wrote innerXHTML.js which extracts from the HTML a consistant XML fragment that Flash can parse. innerXHTML.js is included in the example code we’re releasing to the community.

In your ActionScript code, create a new XML object from the string returned by innerXHTML:

var xmlData:XML = new XML();
    xmlData.ignoreWhite = true;
    xmlData.parseXML(unescape(_root.strXML));

Now the HTML of your page is available as an XML object in Flash.

It’s quiet. Too quiet …

Ideally, a page built with the Faust process will display so seamlessly that a user without Flash will never know what they’re missing. But you probably want to give them some clue to incite them to get the full experience. Here’s how to invite users to upgrade:

<div id="warning">
  To view the videos and animation on this site, please install the latest 
  <a href="http://www.adobe.com/go/getflashplayer">Adobe Flash Player</a>
  <noscript> and activate JavaScript in your browser</noscript>.
</div>

Here’s the JavaScript:

if (deconcept.SWFObjectUtil.getPlayerVersion().major >= 7) {
  var element = document.getElementById("warning");
  element.parentNode.removeChild(element)
}

The warning tells the user to install the Flash Player. If the user doesn’t use JavaScript, they receive the additional warning in the noscript tag. If JavaScript works, and the required version of the Flash Player is installed, we remove the warning.

Examples

The website for Ivy Hotel is an example of Faust in production. Try it without JavaScript. Try it without Flash. Try it without CSS. Same content, all from HTML.

Code Downloads

All code © 2006 space150, LLC. Released under the CPL license

Known Issues

innerXHTML doesn’t work in IE 5.0. We’re working on it.

Read More

UPDATES

January 19, 2007: Added Opera support

January 24, 2007: Fixed a typo in faust-slideshow.html


Comments

  1. Nice post!

    Btw, the reason IE returns HTML with capitalized tag names is that IE doesn’t parse content as XML, even if the document is valid XHTML. It treats everything as HTML, and in HTML tag names are not case sensitive and internally converted to upper case. That’s what you get when you serialize DOM elements in IE.

    Plus, IE won’t render your document at all when you deliver it as application/xhtml+xml (http://www.hixie.ch/advocacy/xhtml)

    -Claus Wahlers / 01.11.07
  2. Very interesting idea. I was going to digg this, but the link is there already:

    http://digg.com/design/Faust_Flash_and_Web_Standards_finally_play_nice

    -Brian Deitte / 01.12.07
  3. Wow, this article is great! My company is putting together a conference dedicated to establishing and highlighting best practices for offering Progressive Enhancement Flash. I’d love to see you there.

    -Justin Kistner / 01.12.07
  4. Amazing… this is by far the best way I’ve seen yet to progressively enhance HTML/CSS content with Javascript and Flash.

    The only issue left is making sure that the Flash content is accessible to all users(especially when it comes to navigation). So far a Flash menu cannot be as accessible to all users as a plain text HTML menu, but the guys behind Flash are working on that. One thing you can do is make the Flash menu scalable, so it can resize with the HTML content as the user increases the text size. I can see that it’s only a matter of time before this becomes a viable AND accessible solution that can work for everyone.

    -Montoya / 01.13.07
  5. Montoya: That’s a good point. With some simple additions, Flash can be set to resize with the page. There’s a write-up here:

    http://sonspring.com/journal/em-flash-sizing

    Justin: I’m interested in the conference. Please let us know when you have more information.

    -Eric Skogen / 01.14.07
  6. This is very much inline with my own efforts. I considered it more of a combination of Flash and AJAX or FLAX. This idea is made possible by the giants that worked out SWFObject.js, the many that worked out innerHTML, and flash 8’s ability to communicate effectively to javascript. I would like to see more of your work like this. My site, stevensouthard.com, was made with a very similar understanding. Good luck with this approach I’m looking forward to seeing where it goes for you.

    -Steven Southard / 01.19.07
  7. Steven: Thanks for your comments. You’re right, the hard work of other developers has given us a lot of room to explore.

    You may find it interesting that the Faust Slideshow example does not require JavaScript for navigation. Even when JavaScript is turned off, a user can choose thumbnails and view pictures. Some sites are coded to strictly require JavaScript for navigation, and potentially lock out users who do not have it.

    We have learned a lot from the “unobtrusive javascript” and “progressive enhancement” techniques others have pioneered. Just a few more ingredients to add to the recipe.

    -Eric Skogen / 01.19.07
  8. Your right with you choice to limit javaScript to areas that are not critical or at least have a fallback plan. Although I am on the same path with my approach your’s sounds like it works a little more consistently. Faust is a lot of work. Many many layers and combining many disciplines. Thanks for the tip I’ll look into the unobtrusive javaScript. Trying to come up with more advanced ways to create websites has its draw backs. There are those people for what ever reason that will try to go to my site with a text reader, a text based browser, any linux based browser, or with javaScript or Flash turned off and for various reasons they will not see what I intended. For my own efforts I see using less and less flash and more CSS and yeah even more javaScript.

    -steven southard / 01.26.07
  9. excelent explanation, thanks…

    -Ruben Rojas / 03.23.07
  10. One thing to keep in mind when quoting penetration rates is that most of the numbers are gathered by snooping browser agents, and among the pool of returned configurations will be embedded systems, public terminals etc. When you say “10% of people don’t have Flash installed” it’s a bit misleading because FAR less than 10% of the target demo for any project that has a budget large enough to warrant Flash development in the first place will be missing the plugin.

    -Andy / 04.06.07
  11. Hi! I’m very grateful for this article about FAUST technique (and so for innerXHTML.js, obviosly). Since I read it, I aplied in the template I was developing for my (wordpress) blog: http://like-spinning-plates.net. It was easy to understand (very clean concept), it was esasy to implement (well, after a bit actionscripting) and now any reader of my blog can read what I write. I really like to use flash for things where HTML can’t.

    Thanks again. I’ll share the knowledge!

    -yellow / 10.23.07
Comments are closed for this article.