M Studio Labs Beaker

M Studio Labs


To save on bandwidth, we often load transparent external images as SWF’s instead of PNG’s. It’s a bit more production work but it makes everything load a whole lot faster, as SWF uses JPEG compression on the image while maintaining the PNG’s transparency.

This requires no extra coding as long as the SWF’s are served from the same domain as your application. If they are not, then you’ll need to prepare the SWF’s with a few lines of Actionscript below.

Let’s say your application is SWF A and is loading in SWF B from another domain. SWF B needs to have a few lines of code in it to allow A to access it’s properties.

Quick note: this applies even if you are using SWF B as a static image or animation with no code. When you load the object and need to test it’s “bytesLoaded”, you’ll need to access it’s LoaderInfo/Loader. This will throw a Security Sandbox (#2121) error unless you add the following to SWF B:

// don't forget to import Security first
import flash.system.Security;

Security.allowDomain("www.swfAdomain.com");

Obviously, www.swfAdomain.com is where SWF A is hosted.

If you are loading SWF B from HTTPS and SWF A is on HTTP, then you’ll need to instead call:

Security.allowInsecureDomain("www.swfAdomain.com");

You can read more about cross-domain issues here.


Leave a Reply




Comment:





About this Blog
This blog is maintained by Alex Motzenbecker at M Studio. This is where I'll try to share our approaches to Flash-related challenges with the rest of the developer community.

I'll post our solutions, any Flash-related news and updates on the work we're doing here. You can send any feedback or hello's to alex [at] mstudio.com.
spacer
Recent Posts
Categories
Favorite Resources