SWFObject 2.0 Beta

Today at Adobe MAX I’ll be giving a presentation with Michael Williams on the next version of SWFObject (previously the SWFFix project). As most of you probably know, I’ve been working on a project with Bobby van der Sluis and Michael Williams (From Adobe) that was going to become the de-facto standard for embedding Flash/Flex content. Well we decided that we didn’t like the new name all that much, so we are adopting the SWFObject name for the project.

The new version is a complete rewrite from SWFObject 1.5, so we’ll need lots of testing before we officially launch it and replace the older SWFObject and UFO scripts, and since we have Adobe involved, they will be including this embed system in the Adobe authoring tools in the future.

The SWFObject project is moving to Google Code, where you can download the source from svn, grab the latest build, or file bugs or read documentation.

I’ve also created a new Google Group for SWFObject support questions and discussion.

If you are at MAX today, our presentation is at 2:45pm in room W-196c and it’s called “Flash Detection and Embedding: An open source solution”.

If you can’t make it today, we’ll be doing it again tomorrw (Wednesday) at 11am in room W-185d.

FlashObject to become SWFObject

A couple of months ago I was asked by Adobe to write an article about FlashObject for their Devnet site. I happily agreed, as the Devnet site is pretty high visibility in the Flash community, and it would really get the word out about FlashObject.

So I wrote the article – nothing too spectacular, just a spiffed up version of the existing FlashObject page. Then I waited. Then came a very odd e-mail: their legal department didn’t like that I used the word “Flash” in the project name, and asked if I would be averse to changing it. Well, I’m not really attached to the name, so I considered it for a bit, but decided that changing the name would be too much hassle, especially since so many people are already using the script and it’s gained quite a word of mouth following. So I imagined that all the people that know about it would hear all about this new great script called SWFObject and think it was some new thing. I can see the conversation now. “No thanks, I don’t need to use SWFObject, I already use FlashObject, and it’s just fine.”

Well I asked Adobe to compromise, and possibly give me permission to use the Flash name. I offered to place a little tag-line along with all the information about it, something like “Flash is a registered trademark of the Adobe Corporation, used with permission.” (Or something like that, you get the point).

Well, a few weeks have gone by, and tonight I finally got the response back: No deal. Apparently Adobe is really clamping down on the people using the word “Flash” in their projects, even if they are open source. I’m not sure how this will affect other projects, or Flash communities (My guess is that communities like OSFlash and Flashcoders will be fine, but anything that distributes a product with the name “Flash” will need to change – but this is just a guess).

Needless to say, I’m slightly annoyed by all of this, but in the end it shouldn’t really affect the project all that much (I hope). Soooo starting immediately, and as I find time to update the documentation and code downloads, FlashObject is now known as SWFObject.* I’ll be updating the main page to redirect to http://blog.deconcept.com/swfobject/ in the next day or so. If you have links pointing to the old page, feel free to update the links and change your link text/other info to SWFObject.

* I’m not really a huge fan of the name SWFObject, but I want to keep the ‘Object’ part in there to at least keep some semblance of recognition in there for the users who are already using the script, or have already heard about it. I also hate when people pronounce SWF as “swiff”, but since this is the internet, it will be hard to force people to call it S.W.F. Object. And that takes more time to say than “S.W.F. Object” anyway. So feel free to call it “Swiff Object” when talking about it “in real life.”

UPDATE (4-27-2006): John Dowdell posted a bit more info about this on his blog. Go read the Adobe Trademark guidelines.

A modern approach to Flash SEO

Search engine optimization is one of the most popular subjects when nerds sit around and talk about Flash. “Does Google index your swf files?” seems to be the most popular question, usually garnering plenty of ‘yes‘ and ‘no’ and ‘maybe’ answers. The real answer to this question, once and for all, is this:

It doesn’t matter.

To understand this answer, you need to understand what Flash is. And to do that, you need to understand modern web development philosophy. First off, you need to embrace web standards. Semantic markup and separating content from style and behavior is the only way you should be building your sites. Many web standardistas have been recommending this method of web development for years, and rightly so. However, this post isn’t the place to go into the whys of this type of development, so I’ll skip that part and just say this about how it’s done: There are three areas of front-end web development: Content, Style, and Behavior. You should always keep these three things separated as much as possible.

That brings up the question: “Where does Flash fit into this three pillar method of web development?” Is it content? Is it behavior? Is it style? While it could be considered all three, most professional Flash developers will remove the content from their Flash movies and load it in using Flash remoting or XML files. That leaves us with style and behavior.

Style is added using CSS. Generally when you add images to your HTML that are purely presentational (no text or required content in them) you should add them in using CSS. In most cases you don’t want Google to index them because people don’t search the web for ‘top left rounded corner gif.” They search for content. Even if Google upgrades their crawler someday to read CSS files and index the images, they probably wouldn’t use the information for more than statistical analysis because of this.

Behavior is generally added using Javascript. Maybe you want a new window to open set to a certain size, or you want to use some fancy Ajax to let users rate something without refreshing the page. This should all be added unobtrusively, and if the browser doesn’t support Javascript, it will hopefully still work. Unfortunately, not everyone considers this, and these days Javascript is becoming more and more of a requirement to use most websites. So you should always provide some sort of alternative for non-Javascript users. When it comes to indexing behavior, Google will for the most part not index your Javascript files. Even if it did, most web users would have no idea what the .js file they are looking at actually does. When using Javascript to change your document, Google will not read the ‘final’ page, but only the raw HTML file. Google does not render Javascript 1.

Now that you know all of this, it’s time to look at how to treat your Flash content. Since we’ve determined we don’t want Google to index our swf files, but we do want it to index the content displayed inside them, what is the best way to go about this?

As stated before, if you are building Flash sites professionally, you probably move all your content out of your Flash movie and into an XML file or keep it in a database. This makes it much easier to allow Google to index this content by using progressive enhancement.

Progressive enhancement is a method of web development that goes hand in hand with Web Standards. You start with your HTML (your content), then add CSS (your look and feel), then add in additional behavior (Javascript, Ajax, Flash, any other interactivity that isn’t handled automatically by the browser).

The best way to add Flash progressively is by using Javascript, or more specifically, a script like FlashObject. First you lay out your page as if you aren’t using Flash. If you are using a database for your content, you can spit out that data as HTML where the Flash movie will go on the page (or maybe just a preview of the content, it’s up to you to show Google the content you would like indexed). Then you use FlashObject to replace this content only if the user has Javascript enabled and the required Flash plugin version.

Here’s a small example of what that might look like:

<div id="flashcontent">
    This is replaced by the Flash content if the user has the correct version of the Flash plugin installed.
    Place your HTML content in here and Google will index it just as it would normal HTML content (because it is HTML content!)
    Use HTML, embed images, anything you would normally place on an HTML page is fine.
</div>
<script type="text/javascript">
    // <![CDATA[
    var fo = new FlashObject("flashmovie.swf", "flashmovie", "300", "300", "8", "#FF6600");
    fo.write("flashcontent");
    // ]]>
</script>

This causes Google to skip the Flash swf files and only index the HTML (the content!) you place on the page. You can place links to other pages, images, whatever you want Google to index, and when a viewer with a browser that supports Flash visits your site, they will then see the Flash content. This gives you full control and much greater predictability over what content Google will index. And if your content is pulled from a database that is editor controlled, your pages will update and be re-indexed as the content changes without the need to re-publish all your swf files.

1 Currently Google does not render the Javascript on a page, but there are rumors that they are developing a new crawler based on Firefox (they employ a number of Mozilla foundation members) that will index pages based on how the browser sees them, instead of the raw HTML content. This means HTML hidden by CSS may not be indexed, and pages that are altered by Javascript after they load will be indexed how they appear to the user. However, this is all rumors and until it happens Google will ignore your Javascript content.

Note: In this article I use the ‘Google’ name often, but it can be interchanged with any search engine, as they all work roughly the same way.