Link to home
Start Free TrialLog in
Avatar of MediaMacros
MediaMacros

asked on

Flash not loading some PNG files via Actionscript

I have a set of PNG files saved from a PHP script on a server.  They work fine in the browser.  I then try to open them in flash. If I import them in authoring it works fine.  If I try to load them via loadMovie I get a solid red rectangle.  I noticed that tehy are about 2 K.  If I resave from fireworks (no changes) they are 33 K and then load fine.  The odd thing is that the image data is there and works otherwise.  ANy ideas as to how to force them to work dynamically?
Avatar of Aneesh Chopra
Aneesh Chopra
Flag of India image

Hi,

As you said that PHP script on a server is actually creating PNG files which you are loading in flash using loadMovie.

I feel that flash is trying to load these files before it gets generated completely on server.
you shouldput a check to test if PNG file has been generated completed then start loading it inside flash.

Rgds
Aneesh
Avatar of MediaMacros
MediaMacros

ASKER

I thought that too so I had it actually save it to the server and redirect instead. I even pointed directly to one of these manually after generation and it failed there too.  The same file loaded in a browser works.  I can also download that file from the browser or via FTP and load it into Flash in authoring and it works, but loading it via loadMovie brings in the red rectangle.

I experimented with Flash's bitmap scaling a bit as another option but it seems to be almost as poor as its scaling of movie clips.  I need a smooth bicubic style scaling that looks clean and anti-aliased.
can I review the online version....
it would help to resolve it faster....

Rgds
Aneesh
Can I get an address to email off list?  I'd rather not post too much of my client's server or URL info here since its still under development.
you may send it to my email..

email is in profile..
I did a small test.....

downloaded png sample generated by your provided url...

and converted the same png using save as png command in Photoshop

next, loaded both sample using loadMovie in a FLA,

I found that, original file were shown as red rectangle (as you said)

but the converted file were shown properly...


this test, proves that your script actually is not generating the png file is required format to be loaded in flash....
here I have uploaded the test source here..

download link:
http://download.yousendit.com/D506A20127654365

Rgds
Aneesh
The odd thing is that some of them do work. IE the letter "B" works while "A" does not.
Also, manually loading the same PNG into Flash in authoring does work.  I think its some sort of bug in how it parses PNG files with load movie.  I'll keep searching for alternatives.  

Do you know of any way to get this better and smoother scaling via Flash's bitmap commands?  That was my first approach but it seems to not dither correctly so the edges of high contrast colors look very blocky.
ASKER CERTIFIED SOLUTION
Avatar of Aneesh Chopra
Aneesh Chopra
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I found a bit of a work around but doing the scaling in the Flash file with bitmap objects.  I load the base PNG that did work, then make a new bitmap object, then put that back in where the clip was using attach bitmap with smoothing set to true.  Its not as nice as the PHP scaling for anti-aliasing but is enough to pass for this project.  
Are you using Flash 8? Only flash 8 can load gif/png dynamically (AFAIK). If yes, please send me your example, I'll try to check it out. My mail is in my profile.
Yes, its Flash 8.  As far as I can tell the simplified PNG files created by the script are just not read by flash via dynamic loading.  It apparently is looking for more info (maybe in the header, etc) than its getting.  Other apps read the files fine but not Flash.  I have a work around using hte bitmap scaling inside of flash but it took a little setup to get it to work. Still not ideal but workable for this project.
So you solved the question yourself. You can ask the mods to remove it, then (Community Support section).
Btw, how do you create these PNGs? What software do you use for it?
The initial PNG file was from Fireworks but the scaled version comes from the server.  It was converted via PGP using the GD imaging library.
So, GD produces bad PNGs, hmm.. linux version?
Not bad per se, just bad for FLash.  The bug may very well be FLash, but I can't find a workable fix.  

JPEGs from GD work fine
Some PNG files work fine, but its inconsistent.

Just as a note teh initial PNG was 33 K.  With no scaling if GD rebuilds it it comes out at around 10-11K, so its definately compressing it better.  No visible quality loss.
No quality loss should be there given that PNG is totally lossless ). I wonder how it does compress it better. AFAIK, GD uses zlib for compression.
Well, if you open the same 11K image in Fireworks and resave its back to 33K.  I think Fireworks and other apps use extra header info, or may use things like 0 in place of null characters for empty pixels.  Just a guess, but that might also explain why Flash does not like some images.  If the lat few bits were null it may see it as an invalid image or partial file.  For import in authoring it would not matter as it can see the entire file length.
Maybe. I don't know PNG internals, either