Creating Optimized Content in Flash - Search Engine Optimization for Flash
by Todd PerkinsNow that you have some experience creating optimized HTML content, take a look at some techniques to make your Flash content more visible to search engines. This chapter discusses search engine optimization (SEO) mainly from the Flash development perspective, focusing on what you need to do for optimization when creating Flash applications.
This excerpt is from Search Engine Optimization for Flash. Search Engine Optimization for Flash dispels the myth that Flash-based websites won't show up in a web search by demonstrating exactly what you can do to make your site fully searchable -- no matter how much Flash it contains. You'll learn best practices for using HTML, CSS and JavaScript, as well as SWFObject, for building sites with Flash that will stand tall in search rankings.
Although they may be legitimate, most of the reasons people don’t like Flash are based on outdated myths regarding the technology’s SEO capabilities. In this section, we’ll look at some of the most prominent myths that create haters out of otherwise normal human folk.
The first myth is that Flash and SEO don’t mix. In other words, some people believe that to have an SEO site, you must eliminate most, if not all, Flash content. This is simply not true. Flash content, when used effectively, can work great with SEO. Other media elements, such as images, audio, and video (including video in Flash Player), are searchable based on the HTML content that surrounds them.
Another myth about Flash content is that search engines can’t search through it to index the information within SWF files. For a long time, this myth was true. Though static text and links in SWF files could be indexed, this was only because Flash added that information to the HTML containing the SWF upon publishing.
Recently, Adobe announced that the Google and Yahoo! search engines received a special version of Flash Player to use in indexing Flash content. This version enables these search engines to crawl through a Flash movie similar to the way they crawl through HTML. As of this writing, Adobe hasn’t released details about how this version of Flash Player works, but it has stated that search engines can index all URLs, dynamic or otherwise, and all text that appears in text fields that people can read. What do you have to do to have search engines index your Flash content? Nothing. They’re already doing it for all pages being crawled.
Although you can use Flash and still have excellent SEO, and although Flash content is now searchable, there are some things to avoid when creating SEO Flash content. In this section, we’ll look at some pitfalls for those of you who are new to Flash SEO, as well as some of the challenges you’ll face when developing your Flash applications.
Many Flash enthusiasts want to create sites entirely in Flash, or sites that use a heavy amount of Flash, using their Flash skills to emulate what’s done with HTML. Although it’s possible to create an all-Flash site that’s optimized for search engines, this is usually discouraged, for a few reasons.
First, optimizing a Flash site using just Flash is possible, but it’s difficult to tell how search engines weight different elements. For example, in HTML, you can weight different elements by placing them in heading tags, by making them bold or italic, or by creating links. In Flash, you can place HTML in text fields and use CSS to control how different elements are weighted, but that doesn’t necessarily mean the Flash versions of the elements will be weighted the same as the HTML versions. In other words, the same elements may hold different (likely, less) weight in Flash.
Further, to be sure your Flash content is weighted correctly, you should also have an HTML description. That way, since you know for sure that HTML content is indexed, you can be sure that at least a description of the content can appear in search results. For now, it’s too early in the game to see whether this can count as duplicate content if your Flash content contains the same information.
If you create a site that’s full of content and you wish to have an HTML alternative for those who don’t have Flash, you might find yourself needing to create an all-HTML website in addition to your all-Flash site. Not only can this be incredibly time-consuming, but also, as I mentioned earlier, this could count as duplicate content.
One of the advantages of using HTML over Flash for an entire website is that HTML allows links to any page of a site. If you create an all-Flash site, or if an extremely complex Flash application is necessary to make your site usable, people coming to your site might have to navigate through your entire application to view the content they want. At a minimum, they might have to go through a few pages, or states, of your application that they don’t want to view before viewing the desired content. This isn’t necessarily bad for SEO, but it’s horrible in terms of user experience.
This link dilemma isn’t impossible to fix, but it will
take some work and workarounds to create a good user experience.
Luckily, the solution isn’t too complex. Using some
ActionScript along with other technologies, you can create
deep links, links that take users to
specific states of your application. You can also create Flash
sites that are made up of multiple web pages, so individual states
of the application can be linked to and so your users can use their
browser’s back and forward buttons.
Flash, like any other content on the Internet, is prone to hacking. Many tools out there allow others to dig into your Flash applications to find assets you’ve used, and even extract all of your ActionScript code. In your Flash applications, try to avoid using private data unless you absolutely need to. Even then, keep in mind that through search engines or hacking, your data can potentially be exposed.
Now we’ll look at what you can do in Flash to create SEO content. We’ll discuss some methods that have been around for a while, as well as some ways to optimize your applications for indexing.
Flash has had built-in tools for SEO ever since Flash MX 2004 was released. Over the years, these features have received some improvements, but they aren’t complete SEO powerhouses yet. In this section, we’ll talk about each method, and their advantages and disadvantages.
SWF files, like HTML, video, and images, can include metadata. You can use this metadata information to give Flash movies titles and descriptions. At this point, search engines, even with the recent advancements of Flash SEO technology, don’t index the metadata information. That’s not to say you should avoid using it altogether. Rather, you might as well add in the metadata information now, and it may work to your advantage in the future. With the advancements in Flash SEO, it’s becoming increasingly likely that this metadata will be used eventually.
The metadata used in SWF files is similar to the metadata used
in other Adobe applications, and it contains information about a
file that’s embedded into the file itself. This is called
XMP metadata. XMP (eXtensible Metadata Platform) metadata can
include many different types of information, and even custom
information, but what’s relevant to SEO is that it can
contain a title and a description.
Adding metadata to a SWF file is extremely simple. One way to open the metadata window is to choose File→File Info. Another way to access the window is through the Publish Settings window, which you can access using the Property Inspector or through the window command File→Publish Settings. In the Publish Settings window, click the Flash tab to set options for publishing Flash content. In the Flash tab, click the File Info button next to the Include XMP Metadata checkbox to open the window used to enter XMP metadata into the SWF file (see Figure 3.1, “Adding XMP metadata to a file”).
Using the metadata window, you can then add XMP metadata, including title and description information, to your SWF file. Like metadata in HTML, this metadata travels with your SWF file once it’s published, providing information about the file’s contents.
Once XMP data is embedded into a file, you can view the metadata in two ways. You can view it in Adobe Bridge, or view it in a text file created by Flash. Either way, you’ll need to turn on the Include XMP Metadata checkbox in Flash’s Publish Settings window, add some XMP metadata, and create a SWF file by selecting Control→Test Movie or by Publishing the File.
It’s easy to view and edit metadata in Adobe Bridge. To view the data in Bridge, open Bridge and browse to the folder where your SWF file with embedded XMP data is located. Once you’re in the proper location, select the SWF file to view its metadata in the Metadata panel (shown at the bottom right of Figure 3.2, “Viewing the SWF file’s XMP metadata in Bridge”). While you’re in Bridge, you can also edit XMP data by clicking the Edit button (the pencil icon) for a field you’d like to edit.
To view metadata as a text file, make sure you select the “Generate size report” checkbox in the Flash tab of the Publish Settings window before you publish your Flash content. After you’ve published your Flash content, you’ll see a plain-text file created in the same folder as your other published content that includes the XMP data. You can view the data (Figure 3.3, “Viewing the file in TextEdit”) by opening the file in any text editor.
Some of the text you enter in Flash will automatically be placed in your published HTML file, and is searchable. This text is limited to text that has been typed manually into a dynamic text field in Flash, without using ActionScript. Though this is a quick and easy way to get Flash text into your HTML code without doing any extra work, relying on this method isn’t the best idea, for a few reasons.
For one, you have little control over how Flash translates your
dynamic text field’s content into HTML. The HTML places the
content of your dynamic text field in a <p> tag, giving little structure to the
HTML. If you were to hand-write the HTML code, you could organize
blocks of text into lists, headings, and so forth.
Next, any links added using the Property Inspector are inserted
into the HTML as standard links, using only the href and target
attributes. This doesn’t allow you to use important SEO
attributes, such as title, in your
links.
Finally, the HTML version of your Flash text is placed in a comment, so only spiders can view the text. Because the text is visible only to spiders, those who don’t have Flash Player installed won’t view any alternative content.
I mentioned earlier that Adobe announced that Google and Yahoo! will now index Flash movies. This opens the doors to an exciting new frontier in Flash SEO. One of the most important issues with Flash SEO is what content is and isn’t indexed. In this section, we’ll look at what Flash content search engines index, and how to optimize Flash applications for search.
How does it work? At this point, few details have been released to the public. What we do know is that Adobe created a version of Flash Player made to crawl through Flash applications. What we don’t know is, well, everything else.
So, what Flash content is searchable? Basically, any text that appears in a text field and any URLs revealed in ActionScript or otherwise are now indexed by search engines. That includes the URLs you want to be indexed, as well as the ones you may not want to be indexed. Essentially, anything in a dynamic text field that a person can see can now be indexed.
To make searchable Flash content, you don’t have to do much, if anything at all. Google and Yahoo! are already indexing the content right now. The content indexed is all Flash content, not just content published for later releases of Flash Player.
Of course, this news is both triumphant and tragic. Triumphant because search engines are doing all the work and you have to do nothing, and tragic because search engines may end up indexing a lot of private data.
Now, you may not want all your Flash text to be indexed. If not for privacy reasons, you may want to have more control over which keywords are used, or you may be using letters as graphical elements. In these cases, simply convert any text to vector outlines (Modify→Break Apart) or import that text as a bitmap graphic. That way, you can have a little more control over which content is indexed and which is not.
If Flash applications can be searched, it’s crucial to
understand how the content is indexed relative to how HTML content
is indexed. At this point, it’s difficult to say, so the best
practice currently is to use HTML in dynamic text fields for SEO in
Flash, along with CSS or the TextFormat class. That way, you have maximum
control over the structure and style of your text fields while
simultaneously optimizing them.
Using HTML text with CSS in ActionScript 3.0 requires a basic to intermediate knowledge of all three languages. In this section, we’ll take a bird’s-eye view of how it works.
First, you’ll need to have some HTML and CSS code to bring into Flash. Table 3.1, “Flash Player 10-supported HTML elements and attributes” lists the HTML elements and attributes that Flash Player 10 supports, as stated in Flash Help.
PROD: The ED/AU provided footnotes for the following two tables, but did not specify where the markers should go. I’ve placed them at the end of the table titles, but you may want to double-check with ED/AU on whether that’s what they want. --Tools
Table 3.1. Flash Player 10-supported HTML elements and attributes[1]
|
Description |
|
|---|---|
|
The
|
|
|
The |
|
|
The |
|
|
The
|
|
|
The The
Flash displays media embedded in a text field at full size. To
specify the dimensions of the media you’re embedding, use the
In general, an image embedded in a text field appears on the
line following the |
|
|
The |
|
|
The |
|
|
The
|
|
|
The
|
|
|
The The
|
|
|
The |
Note
For more details on using HTML in ActionScript 3.0, see the
TextField class in the ActionScript
3.0 Language and Components Reference in Flash Help.
You’ll also need to understand what CSS is supported. Table 3.2, “CSS properties supported by Flash Player 10” lists what CSS is supported in Flash Player 10 (again from Flash Help).
Table 3.2. CSS properties supported by Flash Player 10[2]
|
Usage and supported values |
|
|---|---|
|
Only hexadecimal color values are supported. Named colors (such
as blue) are not supported. Colors are written in the following
format: |
|
|
Supported values are |
|
|
A comma-separated list of fonts to use, in descending order of
desirability. Any font family name can be used. If you specify a
generic font name, it is converted to an appropriate device font.
The following font conversions are available: |
|
|
Only the numeric part of the value is used. Units (px, pt) are not parsed; pixels and points are equivalent. |
|
|
Recognized values are |
|
|
Recognized values are |
|
|
Recognized values are |
|
|
The amount of space that is uniformly distributed between lines. The value specifies the number of pixels that are added after each line. A negative value condenses the space between lines. Only the numeric part of the value is used. Units (px, pt) are not parsed; pixels and points are equivalent. |
|
|
The amount of space that is uniformly distributed between characters. The value specifies the number of pixels that are added after each character. A negative value condenses the space between characters. Only the numeric part of the value is used. Units (px, pt) are not parsed; pixels and points are equivalent. |
|
|
Only the numeric part of the value is used. Units (px, pt) are not parsed; pixels and points are equivalent. |
|
|
Only the numeric part of the value is used. Units (px, pt) are not parsed; pixels and points are equivalent. |
|
|
Recognized values are |
|
|
Recognized values are |
|
|
Only the numeric part of the value is used. Units (px, pt) are not parsed; pixels and points are equivalent. |
Note
For details about using CSS in ActionScript 3.0, see the
StyleSheet class in the ActionScript
3.0 Language and Components Reference in Flash Help.
The ActionScript to load HTML and CSS into Flash will require
you to be somewhat familiar with the language. Basically, you need
to use the URLLoader class to load the
external HTML and CSS files. Once you’ve loaded both files
into Flash, you can parse the styles using an instance of the
StyleSheet class, making it usable, by
using the parseCSS method. From there,
you connect the stylesheet object to a text field by using the text
field’s styleSheet property and
then have the text field display the styled HTML data by using its
htmlText property. That’s it!
Your code may look similar to this example:
var htmlReq:URLRequest = new URLRequest("html.txt");
var cssReq:URLRequest = new URLRequest("styles.css");
var loader:URLLoader = new URLLoader();
var sheet:StyleSheet = new StyleSheet();
var htmlData:String = "";
function fileLoaded(event:Event):void
{
htmlData = loader.data;
loader.removeEventListener(Event.COMPLETE, fileLoaded);
loader.load(cssReq);
loader.addEventListener(Event.COMPLETE, cssLoaded);
}
function cssLoaded(event:Event):void
{
sheet.parseCSS(loader.data);
html_txt.styleSheet = sheet;
html_txt.htmlText = htmlData;
html_txt.autoSize = TextFieldAutoSize.LEFT;
}
loader.load(htmlReq);
loader.addEventListener(Event.COMPLETE, fileLoaded);
One basic advantage to using HTML over Flash for large applications or websites is the fact that HTML provides an easy, natural way to link to various states of the application because an application can be made into several linkable pages.
Earlier in this chapter, I mentioned that you can emulate this functionality in Flash to create a better user experience. In this section, we’ll view three (some effective, some less effective) methods for linking in Flash.
If you use frame labels in Flash, you may be familiar with named anchors. Named anchors are a way for you to communicate to your browser’s back button to create a better user experience in your applications. Sadly, named anchor support extends only to Internet Explorer, and is unsupported in other web browsers. Though named anchors have little support, and thus aren’t considered necessary, we’ll still discuss the process of creating anchors in case you should choose to use them.
You can add named anchors to any keyframe in your
Flash application via the Property Inspector. Simply select a
keyframe, add the name of the anchor to the Label field in the Property Inspector, and choose
“anchor” for the frame label type.
Perhaps the easiest approach to optimizing a Flash application is simply to create multipage applications. So, instead of navigating the application asynchronously, users will be moved to different pages and will have to wait for the pages to load.
The great thing about this tactic is the easiness of it. Instead of using buttons in your site to trigger complex ActionScript or to navigate to frames or frame labels, you simply use URLs. This gives you a fast and easy method for linking to specific states of your application, and for SEO purposes it gives you an application similar to an HTML-based application.
Sadly, as easy as it is, creating multipage sites isn’t necessarily the best way to optimize a Flash application. That’s because one of the big reasons to use Flash is to easily create applications that run asynchronously—without multiple page loads. Waiting for a page load at every change in an application will make your application more similar to its HTML counterpart, which in some ways defeats the purpose of using Flash.
Deep links are the best practice for
linking in Flash SEO, because they allow you to link to any state
of an application and they allow asynchronous navigation. Deep
linking works by using pseudo anchors, which work similar to named
anchors in HTML. You may or may not be familiar with named anchors,
so here’s a quick refresher—named anchors are what you
use in HTML to navigate to a specific part of a page, and they
don’t require a page reload. The idea of deep linking is the
same. The most popular tool for deep linking is SWFAddress, which is JavaScript-based and uses
special addresses to communicate to Flash.
Now that you’re familiar with how to optimize applications in Flash, let’s complete some exercises to practice the different techniques.
In this exercise, you’ll add static text, dynamic text, and metadata to a Flash application to optimize it for search engines.
File: Optimizing.fla
-
Open
Optimizing.flain the Chapter 3, Creating Optimized Content in Flash folder. -
Double click the INFO button at the bottom right of the Stage to enter the mcInfo timeline.
-
Inside the mcInfo movie clip, move to frame 2 and note the descriptive text in the dynamic text field. This content will be embedded into your HTML file when you publish it.
-
Select the first keyframe of the actions layer and open the Actions panel (Window→Actions).
-
In the Actions panel, note the interactive code:
stop(); this.onRollOver = function():Void { gotoAndStop(2); } this.onRollOut = function():Void { gotoAndStop(1); }This code stops the playback of this movie clip, moves to frame 2 when the movie clip is rolled over, and moves back to frame 1 on rollout.
-
Return to the main timeline by clicking Scene 1 at the top of your screen.
-
On the main timeline, select the static text field, Target Time, at the top right of the Stage.
-
Because this text field is not useful for SEO, convert the text to vector shapes by choosing Modify→Break Apart twice.
-
Choose File→Info to add XMP metadata to the file.
-
In the metadata window, add some title and description information (see Figure 3.4, “Entering XMP metadata to the file”), and then click OK when you’re finished to accept the changes you’ve made.
-
Choose File→Publish Settings to open the Publish Settings window.
-
In the Publish Settings window, select the Flash tab and make sure the Include XMP Metadata checkbox is turned on.
-
Click Publish to publish the HTML and SWF files and then close the Publish Settings window by clicking OK.
-
Open the HTML file Flash just created for you in a web browser, and then choose View→Page Source to view the source code. In the source code, scroll to the bottom to view the descriptive text from Flash (see Figure 3.5, “Viewing the auto-embedded HTML description in the source code”).
When you’re optimizing Flash applications, using HTML code can allow you to prioritize content, using links, headings, and other HTML tags. In this exercise, you’ll look at the entire workflow of bringing external HTML into Flash, and how to style the HTML code using CSS.
-
First things first—you’ll need some HTML code to import. In the exercise files for this book, you’ll find
html.txtin the folder for this chapter. Let’s take a look at the HTML code in that file.File:
html.txt<h1><a href="wii-games/xylophone-master.html">Xylophone Master</a></h1> <p>Learn to master playing the xylophone and simultaneously boost your memory!Listen to the computer play notes and simply play them back by moving your mouse or Wii remote up and down over the keys.</p> <h1><a href="wii-games/meteor-blaster.html">Meteor Blaster</a></h1> <p>Shoot meteors with powerful laser cannons! Advance through levels based on your score. Watch your energy meter! Those meteors are relentless!</p> <h1><a href="wii-games/fun-run.html">Fun Run</a></h1> <p>Run a marathon as a giant man, completing up to 26.2 miles in 5 seconds! Move the mouse (or WiiMote) up and down to run. Finish fast to get medals!</p> <h1><a href="wii-games/set-the-clock.html">Set the Clock</a></h1> <p>Rotate the mouse or WiiMote clockwise or counterclockwise to set the big clock to display the same time as the little clock. Race your friends to get the best time! Clock on!</p>
Note
This file is similar to the index page used in Chapter 2, Creating an SEO Website, but without images and DIV tags. For SEO, you can still use links and heading tags to optimize your content. When using HTML for Flash, it’s typically best to stick to text content only, because you have little control over the layout of images.
-
Open
styles.cssin the folder for this chapter, and browse its contents.File:
styles.cssp { font-family: Trebuchet MS, Arial, Helvetica, sans-serif; font-size: 14px; font-weight: normal; color: #FFFFFF; } h1 { color: #9FFF9F; font-size: 20px; font-weight: bold; } a { color: #9FFF9F; text-decoration: none; } a:hover { color: #C8FFC9; text-decoration: underline; }Though CSS in Flash is limited, you can still style paragraphs, headings, and links.
-
Now we’ll look at the ActionScript required. The file
HTML-CSS.flacontains a simple layout with a dynamic text field that has an instance name ofhtml_txt. The first keyframe of the actions layer in that file contains the following code.File:
HTML-CSS.fla(first keyframe of the actions layer)var htmlReq:URLRequest = new URLRequest("html.txt"); var cssReq:URLRequest = new URLRequest("styles.css"); var loader:URLLoader = new URLLoader(); var sheet:StyleSheet = new StyleSheet(); var htmlData:String; function fileLoaded(event:Event):void { htmlData = loader.data; loader.removeEventListener(Event.COMPLETE, fileLoaded); loader.load(cssReq); loader.addEventListener(Event.COMPLETE, cssLoaded); } function cssLoaded(event:Event):void { sheet.parseCSS(loader.data); html_txt.styleSheet = sheet; html_txt.htmlText = htmlData; html_txt.autoSize = TextFieldAutoSize.LEFT; } loader.addEventListener(Event.COMPLETE, fileLoaded); loader.load(htmlReq);Let’s do a quick walkthrough of this code. The first five lines (the ones that begin with “var”) define the variables used. The variables represent the URLs to the HTML and CSS files (
htmlReqandcssReq), the object that will load the data from the files (loader), the ActionScript version of the stylesheet (calledsheet), and the HTML data loaded from the external TXT file:var htmlReq:URLRequest = new URLRequest("html.txt"); var cssReq:URLRequest = new URLRequest("styles.css"); var loader:URLLoader = new URLLoader(); var sheet:StyleSheet = new StyleSheet(); var htmlData:String;At the bottom of the code is where the application begins its work. The
loaderobject loads the URL for the HTML file (loader.load(htmlReq)), and waits for the file to load (loader.addEventListener(Event.COMPLETE, fileLoaded)), at which point thefileLoadedfunction will run:loader.load(htmlReq); loader.addEventListener(Event.COMPLETE, fileLoaded);
The
fileLoadedfunction stores the HTML data within thehtmlDatavariable, disassociates theloaderfrom thefileLoadedfunction, loads the CSS file, and sets thecssLoadedfunction to run once the CSS file is loaded:function fileLoaded(event:Event):void { htmlData = loader.data; loader.removeEventListener(Event.COMPLETE, fileLoaded); loader.load(cssReq); loader.addEventListener(Event.COMPLETE, cssLoaded); }The
cssLoadedfunction parses the loaded CSS code, making it usable in ActionScript, connects the text field on the stage (html_txt) to the stylesheet object, sets the text field to display the HTML text, and sets the text field toautosize:function cssLoaded(event:Event):void { sheet.parseCSS(loader.data); html_txt.styleSheet = sheet; html_txt.htmlText = htmlData; html_txt.autoSize = TextFieldAutoSize.LEFT; } -
Once you’re done viewing the ActionScript in this file, you can see the file in action by choosing Control→Test Movie (shown in Figure 3.6, “Viewing HTML text styled by CSS in Flash Player”).
Table 3.3, “Key terms used in this chapter” contains the terms that were introduced in this chapter and gives you their definitions.






