Flash and crossdomain
The first obstacle is the security box / crossdomain in Flash.
If you want to know more about the security box and crossdomain.xml, visit Martijn de Visser blog, he has an excellent explanation (with images!!!).
But in short, if you want to load images/ xml/ etc from a different server then your own, you need permission (crossdomain.xml) from that server.
This information is given to us by
loadClip (MovieClipLoader.loadClip method) which explains about crossdomain, security box and the MovieClipLoader (this is the method I use to load the images).
And here I seem to run into a bug: it should not be possible to load from another server without a crossdomain.xml, but I can.
When I follow my HTTP traffic between my machine and the Internet (using Charles) I don’t come across a crossdomain.xml when I load images but when I load xml form that same server I don’t get permission to do so (it can’t find a crossdomain.xml and so it’s not allowed to load xml from that server).
Xml loading from another server is not allowed without crossdomain.xml, but images doesn’t seem to be a problem.
What’s the next step for FlashBox?
So for now I don’t have a problem.
But what if it’s NOT possible in the future to load without crossdomain.xml
A possible solution is a proxy.php. I have tested it with xml and this works.
This is how it works:
Instead of trying to get the remote site to cooperate, you can just use a PHP script to retrieve the information for you.
And because one of the successes of this experiment rests on the “smaller then lightbox”, I choose to use the first file, because it’s 1kB.
(this proxy.php could also be a solution but I haven’t tested it!)
What sort of images can Flashbox show
I’ll revere to the documentation, and these are files I test. But perhaps other images files are possible.
Loads a SWF, JPEG, GIF, or PNG file into a movie clip in Flash Player while the original SWF file is playing. Support for unanimated GIF files, PNG files, and progressive JPEG files is added in Flash Player 8. If you load an animated GIF, only the first frame is displayed.
So LightBox will be better in animated Gif, because Flash will only show the first frame of the animated gif. But Flashbox can also show SWF files… So I’ll call it even.
You need a crossdomain.xml at the sites you want to download images from.
Example of a crossdomain.xml:
For Flash Player 8:
- Loading is not allowed if the calling movie clip is in the local-with-file-system sandbox and the loaded movie clip is from a network sandbox.
- Loading is not allowed if the calling SWF file is in a network sandbox and the movie clip to be loaded is local.
- Network sandbox access from the local-trusted or local-with-networking sandbox requires permission from the website by means of a cross-domain policy file.
- Movie clips in the local-with-file-system sandbox may not script movie clips in the local-with-networking sandbox (and the reverse is also prevented).
For Flash Player 7 and later:
- Websites can permit cross-domain access to a resource by means of a cross-domain policy file.
- Scripting between SWF files is restricted based on the origin domain of the SWF files. Use the System.security.allowDomain() method to adjust these restrictions.