While it sometimes causes other timing problems, the framework sets the
properties of a component before rendering the children, and for this
precise reason.

 

Pass the xml into the component from the outside and it will be ready
for use in rendering.

 

Tracy

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Amy
Sent: Thursday, October 23, 2008 9:53 AM
To: [email protected]
Subject: [flexcoders] Re: How to get XML data in before self-configuring
custom component needs it?

 

--- In [email protected] <mailto:flexcoders%40yahoogroups.com>
, "Mic" <[EMAIL PROTECTED]> wrote:
>
> Not a very good description I think :-( A custom component uses XML
> data to build itself. With xml embedded within the AS component
> everything flies:
> 
> var layoutXML:XML =
> <layouts>
> <layout name='View1' description='Single View'>
> <item id='1'>
> <orientation>v</orientation>
> <panes>1</panes>
> </item>
> </layout> etc
> 
> Moving the xml to an external document causes a situation where I
> cannot get the xml in before the component needs it! Earliest I 
think
> is preInitialize, right? Still not there in time. Not sure there is 
a
> way to pause the AS component construct? Since this actually is 
static
> data - 17 different view configs - shall I just leave it embedded?
> Curious to know if there is a way to do the external thing?
> 
> private function loadXML():void{
> var XML_URL:String = "../xml/layouts.xml";
> var myXMLURL:URLRequest = new URLRequest(XML_URL);
> myLoader = new URLLoader(myXMLURL);
> myLoader.addEventListener("complete", xmlLoaded);
> }
> 
> private function xmlLoaded(event:Event):void{
> layoutXML = XML(myLoader.data);
> trace("Data loaded.");
> }

What's the code of the component?

 

Reply via email to