Thursday, February 21, 2008

beware of flash

sorry for the rant, but a couple of things came up today that wasted hours of time for me and are worth filing away in your flash development mental compartment.

adobe releases new flash builds frequently:

you can see what version of flash you have installed here: http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_15507

so what, you say? well, i mention this because i encountered a nasty bug with specific versions of flash 9 and ExternalCallback today. ExternalCallback is the interface that makes it easy to call from javascript into a flash movie. the bug is this: in IE, when a flash movie is inside a <form> tag, a cached flash movie is not properly re-loaded when it is pulled from the cache, and ExternalCallback just stops working. the bug was present or introduced at some point up to 9.0.44.0, but fixed by 9.0.115.0 (so i didn’t see it at first).

the fix (hack, really), is to append a unique querystring value to the .swf filename, so that IE never pulls the movie from the cache. this was acceptable in my case (an 8kb flash movie), but obviously wouldn’t have worked if the movie was larger.

another bug that was present in earlier versions of flash 9 caused IE to crash when a flash object was unloaded as the browser quit. the fix for that is just as nasty; get a load of this:



function cleanUpCounterObjects()
{
var objects = document.getElementsByTagName("object");

for (var i=0; i < objects.length; i++)
{
for (var x in objects[i])
{
if (typeof objects[i][x] == 'function')
objects[i][x] = null;
}
}
}

beforeUnloadCounterObjects = function()
{
//fix for memory bug with flash 9 and IE
__flash_unloadHandler = function(){};
__flash_savedUnloadHandler = function(){};

window.attachEvent( "onunload", cleanUpCounterObjects );
}

if (window.attachEvent)
window.attachEvent( "onbeforeunload", beforeUnloadCounterObjects);

i get it that cross-browser, cross-platform is hard to do, but doing flash development right is almost impossible with adobe’s versioning strategy. seems to me that side-by-side installations would solve all of these problems; developers could say “flash 9.0.45.0 only”, and when users update to 9.0.115.0, they actually just install it side-by-side with 9.0.45.0, so apps released for 9.0.45.0 continue to run in 9.0.45.0! or am i missing something?

again, just make sure you do as much testing as possible in different configurations. you can download older flash versions from adobe here:

http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_14266&sliceId=1

and the flash uninstaller is here:

http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_14157

good luck…

No comments: