A while ago I wrote about swfIR and the “flicker” bug it has. Several people came to that post through Google looking for a fix, so I decided to write one.
What’s the problem
When page loads, images disappear for a fraction of second before replacement. That’s kinda annoying. Go and check an example on swfIR web-site to see what I mean.
How the fixed version looks like
View fixed version
The Fix
You can download modified swfir.js here or manually change your swfir.js.
Legend:
- Inserted lines
- Deleted lines
swfir.js, lines 587 – 607
swfir.js, lines 332 – 346
How it works
I used a technique called “double buffering”. It translates to “draw the graphic in the background, and replace the foreground with it only when it’s ready”.
Original chain of events was:
1. Hide the img
2. Insert flash
3. Draw flash.
The flicker occured between steps 2 and 3.
Modified version works like this:
1. Insert flash
2. Cover the flash with the img
3. Draw flash
4. Hide the img when the flash is ready.
Flicker still does occur, but since flash is under an image it’s invisible to the user.
I had no easy way of determining that flash finished loading, but I noticed that swfir.swf calls resize() method of swfirController when it’s done. So, I put the code that hides the image inside resize() method.
Suggestions
I think even better way would be to call “image hiding code” (separate function?) explicitly from the flash.
Advantages:
- if no flash – no image replacement
- if swfir encounters an error (say, image is on another server) – no image replacement.
May 2nd, 2007 at 1:50 am
[...] German Rumm’s blog said on April 12th, 2007 at 6:05 am: [...]