Search code examples
flashactionscript-3pngtransparencyloader

AS3 Loader ignoring .png transparency


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?


Solution

  • The image doesn't actually have a transparent background...

    alt text
    (source: liranuna.com)

    For your pleasure, fixed image:

    alt text