Please see my blog post about shared code for modules at http://blogs.adobe.com/aharui
The same applies for SWFLoaders. -Alex ________________________________ From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of tyriker Sent: Tuesday, March 13, 2007 11:54 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: Runtime Error Painting Screen for Embedded App Something further I've found that may at least indicate where the error is: If I just include 1 copy of the reporting app in my 'parent' app. It runs fine everytime (other than the other 3 quadrants are blank). If I embed just two copies of the app, the runtime error occurs maybe 50% of the time. Am I doing this wrong, or taking the wrong approach to it? I have one fully functional Flex 2.0.1 (w/ charting) app, and I'm attempting to load that app into a 'parent' app 4 separate times, using SWFLoader. Is there something wrong with this, because it doesn't work for me. I have a feeling if I could serialize all of the actions of the embedded apps, things would work fine, but I haven't found a straight-forward way of doing this yet. By serializing, I mean: Create SWFLoader1, load app into SWFLoader, trigger load function, trigger application complete function, make function call into loaded app, loaded app changes states and paints new screen for its quadrant, repeat for SWFLoader2, SWFLoader3, SWFLoader4... Currently, it seems like the SWFLoaders all load up their copies of the apps, and move along in the process at their own pace, and if more than one of them attempt to change state/paint their quadrant at the same time, a runtime error occurs. Progmatically, what am I doing wrong? I guess I assumed Flex would handle the 4 apps independently, so they wouldn't step on each other? Or is the 'parent' app responsible for painting the quadrants, and so I can't have any of the embedded apps attempt to update their screen (their quadrant) at the same time that another app is doing it? Sorry for the long post, but I'm just trying to find some information to get me on the right path for a solution. Thanks. Tyler --- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> , "tyriker" <[EMAIL PROTECTED]> wrote: > > I've tried finding a solution to this for about two weeks now, and am > at wits end. > > I have a reporting app that upon creationComplete retrieves an XML > file via an HTTPService, switches states to display a BarChart, builds > barSeries objects and adds them to the chart, and is then done. > > The app as a stand-alone Flex app works fine. I then built a second > app, and using SWFLoader, load the first app 4 times into the second > app (makes a dashboard-type app). > > About 90% of the time, I receive the following error at runtime. > > ************ > TypeError: Error #1034: Type Coercion failed: cannot convert > mx.core::[EMAIL PROTECTED] to mx.core.IFactory. > at mx.charts.series::BarSeries/get legendData() > at mx.charts.chartClasses::ChartBase/get legendData() > at mx.charts::Legend/::populateFromArray() > at mx.charts::Legend/mx.charts:Legend::commitProperties() > at mx.core::UIComponent/validateProperties() > at mx.managers::LayoutManager/::validateProperties() > at mx.managers::LayoutManager/::doPhasedInstantiation() > at Function/http://adobe.com/AS3/2006/builtin::apply <http://adobe.com/AS3/2006/builtin::apply> () > at mx.core::UIComponent/::callLaterDispatcher2() > at mx.core::UIComponent/::callLaterDispatcher() > ************ > > The other 10% of the time, 4 different charts will show up as > expected. The problem seems related to the Flash/Flex player > attempting to draw the charts into the app. Anyone have any ideas I > could try? I've tried a number of things that haven't resolved this yet. > > One interesting thing I found in troubleshooting this: I changed the > reporting app's starting state to the chart state (so it doesn't have > to change state). The runtime error that show up in this instance is: > > ************ > TypeError: Error #1034: Type Coercion failed: cannot convert > mx.graphics::[EMAIL PROTECTED] to mx.graphics.IStroke. > at mx.charts::AxisRenderer/mx.charts:AxisRenderer::measure() > at mx.core::UIComponent/::measureSizes() > at mx.core::UIComponent/validateSize() > at mx.managers::LayoutManager/validateClient() > at mx.core::UIComponent/validateNow() > at mx.core::UIComponent/::creationCompleteHandler() > at > flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEven tFunction() > at flash.events::EventDispatcher/dispatchEvent() > at mx.core::UIComponent/dispatchEvent() > at mx.core::UIComponent/set initialized() > at mx.managers::LayoutManager/::doPhasedInstantiation() > at Function/http://adobe.com/AS3/2006/builtin::apply <http://adobe.com/AS3/2006/builtin::apply> () > at mx.core::UIComponent/::callLaterDispatcher2() > at mx.core::UIComponent/::callLaterDispatcher() > ************ > > ANYTHING would be helpful at this point. Thanks! >