OSempire
Go Back   OS Webmaster Community > Webmaster Forum & Marketplace
Validating Flash XHTML Strict
By justme at 2006-02-11 17:43

Flash applications of one sort or another are an integral part of most websites these days and while they may look pretty, they rarely validate XHTML Strict. This is frustrating if you want a cool-looking website that's also standards-compliant. So, I thought it might be useful to demonstrate by example how to clean up a Flash application and dress it up in xhtml finery for validation - a 'flashectomy', of sorts. If not, one can always play the games.

game_console_img

The following code is for the Flash game console above - right out of the box - complete with 27 errors. Not only is it an ugly block of code, but it doesn't come close to validating, either:

<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,0,0"
WIDTH="535" HEIGHT="228" id="games2">
<PARAM NAME="movie" VALUE="games2.swf">
<PARAM NAME="quality" VALUE="high"><PARAM NAME="bgcolor"
VALUE="#150186">
<EMBED src="/community/games2.swf" quality="high" bgcolor="#150186" WIDTH="535" HEIGHT="228" NAME="games2" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"> </embed> </object>

Click to View and Validate Console Before

Fortunately, getting this game console to validate is pretty much a matter of simply stripping out duplicated and erroneous information and replacing it with xhtml.

There are two main tags used - <embed> and <object>; and since the <embed> element isn't recognized by xhtml, won't validate, and is mostly duplicated data, anyway - out it goes - leaving the '<object>' tags:

<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,0,0"
WIDTH="535" HEIGHT="228" id="games2"><PARAM NAME="movie"
VALUE="games2.swf">
<PARAM NAME="quality" VALUE="high"><PARAM NAME="bgcolor"
VALUE="#150186">
</object>

Next, <OBJECT classid="#" is replaced with the cleaner, shorter xhtml version: <object type="application/x-shockwave-flash" (kinda' like: <style type="text/css"> or <script type="text/javascript">); and finally, codebase="#" is replaced with: data="games2.swf" (for the address of the movie) leaving the final markup looking like this:

<object type="application/x-shockwave-flash" data="http://www.dystopiad.com/validating/games2.swf" width="535" height="228" id="games2"><param name="movie" value="games2.swf"/> </object>

Click to View and Validate Console After

That's it - a cleaner, meaner, shorter markup for a game console that validates XHTML Strict! This method seems to work just fine with other Flash applications, too - like headers, for example - although it has some limitations with longer Flash movies in that the whole movie has to load before it starts playing.

Pacman, anyone?

Lon Allen - Dystopiad.com - Canada's Political and Drug Reform Forum


by OS-Mark on Sat, 2006-02-11 18:37
Great job, much needed article for a lot folks I'm sure. It baffles me why these software companies who's products produce code don't make it valid. I remember struggling to get flash to validate, always afraid of deleting something "important"... then you realize you can safley remove most of the code... fluff.

by John on Sun, 2006-02-12 16:14
Excellent work, I have been looking for it for more than 5-6 days, I found a lot but your one is very easy. THanks for sharing.

by grafx on Mon, 2006-02-13 22:25
I tried viewing the article but the flash movie needs to load before it shows the rest of the text (it loads very slooow at some points). Any chance of removing the flash movie? and just linking to it? I think this would make this great article faster hence easier to read at peak hours.

Awesome job!

by Ryan on Sun, 2006-02-19 20:25
BookMarked! Thanks for sharing this

by jansieblom on Sat, 2006-10-28 13:39
hi

i use swishmax to create flash apps with. i tried this majigger of yours, but it doesn't seem to work in IE, firefox or dopera. am i missing something? i mean, how hard could it be?

by jansieblom on Sat, 2006-10-28 13:48
ok so it was my own dumbness. got it right with closer inspection. thanks for the coffee.

by OS-Mark on Sat, 2006-10-28 13:49
hehe glad you got it working

 
Who's online
There are currently 3 users and 45 guests online.



Powered by vBulletin Copyright ©2000 - 2010, , Jelsoft Enterprises Ltd