Hello EveryBody !

I have a custom component (News) which is called after retrieving
datas from a db with amfphp.
Datas are ok and put in an ArrayCollection (getNewsArray).
But when I make an AddChild(news) to a Tile component within a loop,
only the first two results
show up ???
I have to click again on the firing button to get the third result,
and click again to get the fourth !

Thx for any idea !

Code snippet below :

News Component :

<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"; width="480" 
height="230" creationComplete="initNews()" creationPolicy="all"> 
<mx:Label id="lbl_titre_news" x="10" y="10" fontWeight="bold"/> 
<mx:TextArea id="txta_news" x="10" y="36" height="160" width="295" 
wordWrap="true"/> 
<mx:Label id="lbl_aut_news" x="10" y="203" fontStyle="italic"/> 
<mx:Image id="img_news" x="313" y="36" width="157" height="118"/> 
</mx:Canvas>


Action Script :

private function afficheNews():void 
{ 
for ( var i:int=0; i < getNewsArray.length; i++ ) 
{ 
news = new News(); 
//I call the addChild here because otherwise the children of my News
component
are not yet created... I guess the problem is here, but don't know how
to solve it :-( 
ti_news.addChild( news ); 
news.lbl_titre_news.text = getNewsArray[i].titre_news; 
news.txta_news.text = getNewsArray[i].txt_news; 
news.lbl_aut_news.text = getNewsArray[i].aut_news; 
if ( getNewsArray[i].src_img != null ) 
{ 
news.img_news.source = getNewsArray[i].src_img; 
} 
else 
{ 
news.img_news.visible = false; 
news.txta_news.width = 460; 
} 
} 
}

Main Application :

<mx:Tile id="ti_news" direction="vertical" y="35" > 
</mx:Tile> 
....... 
<mx:LinkButton label="Admin" click="afficheNews()"/> 



Reply via email to