Just some quick information on something I found today. When loading multiple SWFs into a main SWF there are some important issues to consider, especially with library assets.
A breakdown of my situation: I had had a textfield on the main stage of my main movie. I was loading a menu into a loader object in the main movie. In the menu SWF a ComboBox component was added to the stage via ActionScript 3.0. When the ComboBox changes some text is added to the textfield. This all worked perfectly.
When I changed the textfield to a TextArea component I received this error in the output panel:
TypeError: Error #2007: Parameter child must be non-null. at flash.display::DisplayObjectContainer/addChildAt() at fl.controls::BaseButton/fl.controls:BaseButton::drawBackground() at fl.controls::BaseButton/fl.controls:BaseButton::draw() at fl.core::UIComponent/drawNow() at fl.controls::ScrollBar/fl.controls:ScrollBar::draw() at fl.controls::UIScrollBar/fl.controls:UIScrollBar::draw() at fl.core::UIComponent/drawNow() at fl.controls::TextArea/fl.controls:TextArea::updateScrollBars() at fl.controls::TextArea/fl.controls:TextArea::drawLayout() at fl.controls::TextArea/fl.controls:TextArea::draw() at fl.core::UIComponent/::callLaterDispatcher() |
So, why did this happen?
Originally, I was attaching a ComboBox which was stored in the Menu’s library. The main movie’s SWF was empty so the loaded asset was looking for a component in the library of the main movie. When there was nothing there it looked in the menu’s library and found the ComboBox. But, when I added the TextArea component to the library of the main movie, that library became the main asset holder ( Not sure about the terminology ). So, any asset being accessed via a library now came from the main movie’s library. When I added a ComboBox to the main library, the problem was solved.
If there are any exceptions to this, or anyone has a different story. Please leave a comment. Thanks.
Update for ActionScript 3.0
In ActionScript 3.0, every SWF has an Application Domain. The default Application Domain for an SWF and all SWFs that load into it is set by the root SWF. Therefore, when an SWF loads in, it looks to the root SWF’s library for its component parts. This is why, if we don’t modify the ApplicationDomain, we need to have all the components in the root SWF’s library in order to avoid the error.
If, however, we load external SWFs into a new Application Domain, we can isolate the loaded SWF’s library from the root Application Domain. This means the loaded SWF will only refer to its own library in its own Application domain for its component parts. This removes the need to have all its components in the root SWF’s library.
So, to clarify this functionality please refer to ApplicationDomain in the Adobe LiveDocs. Use ApplicationDomain and its various features to manage access to the various libraries of your projects. A great example of when to use this is to secure shared libraries for component parts of an application, or when you want to avoid overloading your root SWF with components and only make them available to the SWFs that will actually use them.

