views:

1296

answers:

3

In Flash CS4, open a new document, change the background colour to something recognizeable (like magenta) and add the following code:

var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, function(e:Event){addChild(e.target.content);});
loader.load(new URLRequest('newsnakelub8.png'));

... replacing the .png filename with any you happen to have handy, I grabbed this one. Compile the .swf, and join me in a sigh of disapointment - the normally transparent .png now has a white background, not allowing the flash background colour to show through.

Is there a magical 'treatAsPNG24' property that I'm missing somewhere?

+1  A: 

The problem is your png. Try opening it in Photoshop and it won't be transparent there either. Try a different one - google it, or publish one from Flash or PS - and it will work fine. (That is, there's no setting to invoke, you just need a proper image.)

fenomas
+2  A: 
LiraNuna
I was all ready to get defensive and be like, "Uh, yeah, of course it does," but you're right, it really doesn't. I feel dumb.
matt lohkamp
A: 

Since it's better to teach you how to fish...

If you're using GIMP 2 (free as in beer), just open the image, select Layer | Transparency... | Color to Alpha and pick the color you want to be converted to the transparent background.

Vladimir
"Color to Alpha" sometimes makes stuff worse, I suggest using the "pick color" tool or the magic wand, "Add alpha channel" and then erasing the color in such an image case.
LiraNuna
"I don't know, what I don't know": thanks for the tip.
Vladimir