views:

1242

answers:

2

Hi,

We have a widget (SWF) that needs to be broken into two SWFs. The main SWF will contain all the programming and business logic and it will also load a second SWF file which will contain the assets, fonts etc.

I have limited experience in Flash but I know it can be done in Flex. Anyway here we have to do it in Flash CS3. Will it be possible to do this in Flash? If yes, what are the steps we need to follow?

Thanks, Sri

+2  A: 

Have a look at the Loader class. Code can be simpler than the one in the Example, but it's a start. There is a well explained tutorial on the flashandmath.com website.

In you main fla ( with logic ), create a Loader, tell it to load the assets, on Event.INIT, use the assets.

George Profenza
+2  A: 

When loading assets from an external SWF it is often useful to instantiate classes stored in the external SWF - for example Fonts are often accessed that way.

When doing such, you have to make sure that your local SWF has the definition of these classes, and simply compiling both SWF files together does not guarantee that. More specifically, if on SWF is dependent on classes in another, then both SWF files end up carrying copies of the class definitions and when you load the external SWF file in the runtime you get casting errors because the VM doesn't know that the same named class in an external SWF is the exact same as the one you have.

In order to work around the problem you need to use ApplicationDomain.getDefinition() on the loaded SWF - see here for a detailed example. In addition to a detailed example on how to use Loader they also show how to get Class objects from an external SWF.

Guss