Friday 9 February 2007

Flash but not of the Gordon variety

We all like a bit of Flash, not too much so that it ends up taking over your entire page and looking like something hideous from the 90's where we all thought the more flash the better. But just enough to add to enhance your page. This week I have had the pleasure of using flash for some interactive maps and for some animated buttons on a home page. Now the first issue I, and I'm sure a lot of other people, have is how you should embed these flash objects into your code. Now rather cleverly I have just mentioned the two ways, embed or use objects, but this post isn't about the method you use but rather my experience with 's Bobby van der Sluis UFO. Now I have used UFO a few times in the past and never had any problems, in fact to be honest its always been a painless experience. yesterday though proved to me that sometimes things just happen and when they do it sucks :( I managed to find myself in the rather odd situation where one of my pages worked totally fine in Firefox, IE7, Safari and Opera but in our favourite browser, IE6 It totally crashed the browser after loading the header. When I mean crash I mean IE eats your memory alive and consumes as much virtual memory as possible and then chews up your PC and spits it at you. Nice. I straight away knew it was due to the fact I had multiple flash objects on the page and some how it was memory leaking. A few Google searches later and after revisting the UFO site I found this enlightening bit of information.

Q How do I fix a "Line 56: Out of Memory" error, when unloading a page in Internet Explorer using Flash Player 9 and multiple SWFs using ExternalInterface? A This is a Flash Player 9 bug I instantly thought this was the problem as it sounded roughly about right and could easily be transferred on to my issue. I implemented the javascript fix and thought off we go lets try this again. One quick refresh later and I was again out of virtual memory and a PC that was as good as a feather paperweight. So back to the drawing board for me, I decided that there must be something daft, lets go through and disable all the flash objects within the page and then activate each one, and see if the problem is specific to one object. Due to the ultimate law that is Sod's law it so happened to be that the last flash file I activated was the one that pushed it over the edge and into the ever downward spiral. To cut a long story a paragraph shorter so that I can go get some sleep I had found a very blatant bug that I should have spotted sooner. Within the ID attribute of the 6'ths flash div container a naughty whitespace had appeared, instead of flashcontainer6 the code had flash container6. Amazingly though was the fact that no other browser was put off by this and ran fine, it was only IE6 that fell on its face. Now to be honest I havn't looked into the matter further to find out why this was the case, my suspicions lie in the way IE6 handles DOM but then as it's using javascript to create the flash object maybe its the javascript engine in IE6 working with the DOM. So take note, if you ever have your IE6 browser crash when trying to run a flash file using UFO, or maybe even SWF, check your ID tags for whitespace!

No comments: