开发者

Detect if .swf has transparent background

Is there a way to do this programmatically in PHP, Python or Java?

Use 开发者_StackOverflowcase:

  • User uploads .swf through an upload form.
  • Detect if it has a transparent background.
  • If it does, change it to something else, e.g. white.


This is very difficult to determine, because all SWFs are actually transparent (or they all can be) - it's just that they can contain shapes which cover the entire stage, which make them appear non-transparent.

To determine this programmatically, you'd need to loop over every shape in the SWF and look at it's bounds. However, that wont be enough since any shapes can be changed by ActionScript blocks and new shapes can be created at run time.

But really, making them transparent is the hard task. Since you want to make sure they're are non-transparent, you can just deal with this at display time - put a colored div behind the object or embed tag.


Probably impossible. I suggest a checkbox on the upload form "This flash app looks best with a transparent background".

Here is a flash app that has - a transparent background to start - a slider that lets you adjust the opacity

As you can see it would be impossible to say "transparent" or "opaque"


As far as I know you can't get the background alpha (transparency) of a swf file. what I would do if I were you would put the uploaded swf into a container swf (load the uploaded swf inside it) which only has a background color of your choice.

There used to be a php swf reader in this link. But I didn't see any alpha information in it aswell.


Flash is a bunch of compiled binary data. You Might be able to hunt down a third party library which can un-compile the flash file and get some of the data from the root movie scene, but it's a large stretch. As others have recommended, a checkbox during upload would be the best route to take.


I think you can read the .html where the .swf is placed and see if there is a parameter called "wmode" and is set to "transparent"

If that's the case you can get the html file and read it with Python, Java or PHP.

It's an ugly solution, but it's a solution.

PS: Sorry for my poor English.


The swf files are handled by plugins running inside or outside the browser. There is no way to tell if a certain flash has or hasn't transparent background... i guess you can assume that all of them are transparent..

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜