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.

Advertisements

Posted on 17 October, 2012, in Actionscript 3, Programming and tagged , , , , , , . Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: