I wasn't familiar with modules, but I read up a bit on them. Sounds
ideal for what I will be doing, but maybe I'll tackle that later.
So I changed my event listeners like you described. That part works
great! I no longer have to take the 'hacky' approach of trying again
every 1 second after the app has been loaded. Thanks for that.
But, my initial problem still exists. About 1 in 20 launches, the
everything works fine. The other times I get the runtime error. Again,
the error is:
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()[C:\dev\flex_201_gmc\sdk\framew\
orks\mx\core\UIComponent.as:5300]
at
mx.managers::LayoutManager/mx.managers:LayoutManager::validateProperties\
()[C:\dev\flex_201_gmc\sdk\frameworks\mx\managers\LayoutManager.as:517]
at
mx.managers::LayoutManager/mx.managers:LayoutManager::doPhasedInstantiat\
ion()[C:\dev\flex_201_gmc\sdk\frameworks\mx\managers\LayoutManager.as:63\
7]
at Function/http://adobe.com/AS3/2006/builtin::apply()
at
mx.core::UIComponent/mx.core:UIComponent::callLaterDispatcher2()[C:\dev\\
flex_201_gmc\sdk\frameworks\mx\core\UIComponent.as:7909]
at
mx.core::UIComponent/mx.core:UIComponent::callLaterDispatcher()[C:\dev\f\
lex_201_gmc\sdk\frameworks\mx\core\UIComponent.as:7852]
So I commented out the lines that deal with BarSeries Objects (it was
about 5 lines of code). Running the loaded app as a stand-alone app
still works fine (other than my chart has no bars). Running it loaded
inside the other app results in a very similar runtime error, but this
time:
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/mx.core:UIComponent::measureSizes()[C:\dev\flex_201\
_gmc\sdk\frameworks\mx\core\UIComponent.as:5448]
at
mx.core::UIComponent/validateSize()[C:\dev\flex_201_gmc\sdk\frameworks\m\
x\core\UIComponent.as:5394]
at
mx.managers::LayoutManager/mx.managers:LayoutManager::validateSize()[C:\\
dev\flex_201_gmc\sdk\frameworks\mx\managers\LayoutManager.as:557]
at
mx.managers::LayoutManager/mx.managers:LayoutManager::doPhasedInstantiat\
ion()[C:\dev\flex_201_gmc\sdk\frameworks\mx\managers\LayoutManager.as:64\
6]
at Function/http://adobe.com/AS3/2006/builtin::apply()
at
mx.core::UIComponent/mx.core:UIComponent::callLaterDispatcher2()[C:\dev\\
flex_201_gmc\sdk\frameworks\mx\core\UIComponent.as:7909]
at
mx.core::UIComponent/mx.core:UIComponent::callLaterDispatcher()[C:\dev\f\
lex_201_gmc\sdk\frameworks\mx\core\UIComponent.as:7852]
Again, it works about 1 in 20 attempts.
Talk about frustrating! It still seems like the items inside of the
state I changed to aren't ready before I try to manipulate them. Or
something, I don't know? Do you suppose I need to setup some listener on
the state that says, once the state is fully loaded, then run the state
manipulation code? Maybe I'll try something like that.
Thanks again.
Tyler
--- In [email protected], "Angus Johnson" <[EMAIL PROTECTED]>
wrote:
>
> Hi Tyler,
>
> Since your swfloaders are applications you can listen for the
> applicationComplete event via the swfloader.content property. This
event
> fires when all children have issued creationComplete events (including
your
> viewstack). You don't have to worry about using a timer.
>
> Set up your listeners on the swfloader as you are currently doing but
add
> one for the INIT event. In the event handler you can add another
listener on
> swfloader.content (your sub application). For example.
>
> private function handleInit(event:Event):void
> {
> _swfloader.content.addEventListener(
> FlexEvent.APPLICATION_COMPLETE, handleApplicationLoaded);
> }
>
> private function handleApplicationLoaded(event:Event):void
> {
> _applicationLoaded = true;
> dispatchEvent(new SWFAppEvent( SWFAppEvent.READY ));
> }
>
> In the above code I am waiting for my custom event READY to fire
before I
> start referencing it in the parent.
>
> This is something I did before modules was included in the framework
so
> there might be some duplication ?? Have you looked at modules?
>
> Hope that helps.
>
> Cheers
> Angus