Thursday, December 22, 2005

Flash Player 8 for Linux update

Update (10/31/06): I still see tons of people reading this old entry. Please read this for up to date information. A beta is now available.

Emmy Huang, Product Manager of the Flash Player, explains what the plans concerning the Linux version of Flash Player 8 are. Instead of releasing a 8.0 version we will directly move to 8.5 on Linux. This will avoid even more delay after we ship Flash Player 8.5 for Windows and Mac. That will also make sure that the new virtual machine works using gcc from start. I see that as a big benefit as gcc is a more strict and standards compliant compiler than Visual Studio or CodeWarrior.

We have a few very good engineers working on the Linux version right now in parallel to the work we do for 8.5. 64bit versions will take a little longer, there are no definite plans just yet. Just recompiling will not work unlike what you might think. The main issue here is the x86 JIT in the virtual machine and the mark&sweep garbage collection which are not 64bit aware right now, work on 32bit pointers only. Adding and testing this is not a small task as anyone who ever worked on this type of low level infrastructure might be able to attest. I can really only ask for patience here, we are aware that we need to offer a solution as soon as possible.

Sunday, December 18, 2005

Dynamically loading bitmaps with smoothing in Flash Player 8

We have gotten a bunch of feedback on this oversight in Flash Player 8. Well oversight might be an understatement, it's really a bug. When you dynamically load a bitmap in a Flash 8 file, smoothing is always turned off and rotating or scaling an image will yield ugly artifacts. Originally I made this choice for performance reasons, as smoothed display is much slower than the standard 'nearest neighbour' scaling method. Little did I know that there would be an uproar among users :-)

Now, there is some good news. Flash Player 8.5 will fix this for AS3.0 and we will even add a new property to the AS2.0 MovieClip class which will allow you to turn this on and off dynamically. The current name of that boolean property is MovieClip.forceSmoothing, which subject for change though. This property will be enabled for version 8 Flash content also, not only 8.5. Once we update the Flash Player 8.5 alpha on the labs site (I can't tell you when/how/if this will happen since I do not know) you should definitely check it out and give us feedback on it.

In the meantime there is a workaround using BitmapData which has been floating around already. For those of you who have not played with the BitmapData object yet and feel left out, let me post a little snippet which will do the job:

import flash.display.*;

function loadBitmapSmoothed(url:String, target:MovieClip) {
// Create a movie clip which will contain our
// unsmoothed bitmap
var bmc:MovieClip = target.createEmptyMovieClip(
"bmc",
target.getNextHighestDepth());

// Create a listener which will notify us when
// the bitmap loaded successfully
var listener:Object = new Object();

// Track the target
listener.tmc = target;

// If the bitmap loaded successfully we redraw the
// movie into a BitmapData object and then attach
// that BitmapData to the target movie clip with
// the smoothing flag turned on.
listener.onLoadInit = function(mc:MovieClip) {
mc._visible = false;

var bitmap:BitmapData = new BitmapData(
mc._width,
mc._height,
true);

this.tmc.attachBitmap(
bitmap,
this.tmc.getNextHighestDepth(),
"auto",
true);

bitmap.draw(mc);
};

// Do it, load the bitmap now
var loader:MovieClipLoader = new MovieClipLoader();
loader.addListener(listener);
loader.loadClip(url, bmc);
}

To use this snippet simple paste the function into your code and then load a bitmap this way f.ex.:

createEmptyMovieClip("myMC",getNextHighestDepth());
loadBitmapSmoothed("mypic.jpg",myMC);

This leaves you with a movie clip which contains the smoothed bitmap. Here is a sample .fla and .swf. Obviously this snippet might not be exactly suitable for your needs, especially if you need to handle loading events, but it should give you an idea how it generally works.