Blog Archives

How an embedded swf messes up your code and how to avoid that

When you embed another swf into your code, maybe this operation will break everything appart. That depends on the classes you use. If these classes have same names but different functions here’s your reason.

The problem is that these swfs share the same application domain. You have to set a LoaderContext with the parameter allowCodeImport to true, but if you want to make them completely seperate, then in the same LoaderContext you’ll have to set a new ApplicationDomain. That sets the two swfs seperate, but that also means that both of them can’t communicate with each other, and neither share the same stage property. So you won’t be able to dispatch any events, except set the initial LoaderContext parameters.

That thing took me some hours to find out…

One last, maybe useful thing. You can also embed a swf, but it won’t work as is. The embed must set the mimeType=”application/octet-stream” variable. That’ll make the swf a ByteArray. After that, you can load it with a Loader, as you would load an external class by instantiating with the new keyword.