This content has been marked as final. Show 3 replies
Weldome to the very dificult topic of application domains.
This error is due to an idiosyncracy in how classes are identified in Flex 2. Each instance of an application has its own set of classes (application domain). The UIComponent in the main SWF has a different identifier than the one in the loaded SWF, and the second instance of the loaded SWF has yet another identifier because a separate application domain is set up for each instance of a SWF. To get things to work, they have to match, by having everybody share the same class.
This works for UIComponent because loaded SWFs are configured to use the classes in the loading SWF if they already exist. I'll bet that if you put a columnChart in the loading SWF things will get better.
That's not always a satisfactory solution because then the loading SWF is sort of bloated, so then you have to try other configurations to get things share classes properly. One configuration is to put the charts in an RSL and load that at run-time and then make instances of the Chart. Another is to put the shared asset (I'm guessing you customized the axis stroke?) in the main swf or RSL and load that before you load the Chart SWF.
What is probably happening underneath for you is that the first instance sets up the styles for the columnChart including the custom axis stroke. The second instance is going to end up using that set of styles including the first instance's axisStroke which is illegal because it is in an application domain that is off-limits. They can only share the loading SWFs classes, and not the sibling SWFs classes. Unfortunately, style definitions are global.
How you solve this problem will be somewhat dependent on whether you are only going to load two instances or N instances and how many other assets need to be shared, and how comfortable you are with RSLs
You are right, I need to create a RSL for my charting components, this will actually solve my problem. Thanks for the pointer!!
Is it just the styles that cause this problem?
AKA, if I add all the styles (rather than using a referenced CSS doc) I need inline will this problem go away?