Sounds like you've got a problem with timing of events, and you're not
calling an invalidateSomething() that you should be, but you're getting the
desired results anyway just through blind luck. Or perhaps your creating the
components later than you should be (or on the wrong event) as well.

-Josh

On Fri, Jun 13, 2008 at 1:10 PM, Body Works Studio <[EMAIL PROTECTED]>
wrote:

>   Hello all,
>
> I am having an issue with the component I am using for my itemRender
> on a list. The itemRenderer is canvas based, and I have the main
> layout done in mxml. in the layout I have a VBox with and id of
> metadataList.
>
> on load I run a function that pulls together content from an
> arraycollection and an object (hashMap). in the function I dynamically
> build and add children to the metadataList. Most of the children are
> labels, but I also use the flowContainer with button children to do a
> tag cloud type listing. Most of the time this works correctly.
>
> Here is the Problem. Every so often the row will render but the action
> script spawned children do not display in the metadataList on load. if
> I scroll down the page and back the row will show with the children
> rendered properly. Also if you hold the mouse on the scroll and go
> fast up and down the list, random rows will loose the children of
> meadataList.
>
> Here is the code for metadataList:
>
> <mx:VBox id="metadataList" width="100%" height="100%" verticalGap="0"/>
>
> Here is the function that populates metadatalist:
>
> protected function addMetaData( stop:int = -1 ):int
> {
> var metadataHeight:int = 0;
> var items:ArrayCollection = Reference( data ).metaData.items;
> var len:int = stop == -1 ? items.length : stop;
> var matches:Object = Reference( data ).metaData.matches;
> var tagMax:Number = 0;
> var tagMin:Number = 100;
>
> // Clear the children since we're changing data
> metadataList.removeAllChildren();
>
> for( var idx:int = 0; idx < len; idx++ )
> {
> var item:MetadataItem = items.getItemAt(idx) as MetadataItem;
> var tagCloud:FlowContainer = new FlowContainer();
> var label:Text = new Text();
> var metadataText:String;
> var word:String;
> var tagScore:Number;
> switch (item.name)
> {
> case Constants.KNOWLEDGE_MODEL:
> if(Constants.IS_LOCAL){
> }else{
> var kmLength:int = item.name.length + item.value.length;
> var textHeight:int = (kmLength/40 + 1) * 16;
> metadataHeight += textHeight;
> // building tagCloud.
> tagCloud.width = metadataList.width;
> // Add tagCloud to the metadataList VBox
> metadataList.addChild( tagCloud );
> var last:int = items.length - 1;
> var words:Array = item.value.split("; ");
> for(var idx2:int = 0; idx2 < words.length; idx2++)
> {
> word = words[idx2];
> tagScore = matches[word];
> tagMax = Math.max(tagScore, tagMax);
> tagMin = Math.min(tagScore, tagMin);
> }
> for(var idx3:int = 0; idx3 < words.length; idx3++)
> {
> word = words[idx3];
> tagScore = matches[word];
> var tagLabel:Button = new Button();
> tagLabel.label = word;
> tagLabel.alpha = 0.0;
> tagLabel.toolTip = Constants.RELEVANCE + ": " + tagScore.toFixed(2) + "%"
>
> var tagDiff:Number = (tagMax + tagMin) / 2;
>
> if (tagScore == tagMin)
> tagLabel.styleName = "tagCloudSmall";
> else if (tagScore > tagMin && tagScore < tagDiff)
> tagLabel.styleName = "tagCloudMedium";
> else if (tagScore < tagMax && tagScore > tagDiff)
> tagLabel.styleName = "tagCloudLarge";
> else if (tagScore == tagMax)
> tagLabel.styleName = "tagCloudLarger";
> else
> tagLabel.styleName = "tagCloudMedium";
>
> tagCloud.addChild( tagLabel );
> }
> // Add HRule to the metadataList VBox under Tag Cloud
> var tagCloudHR:HRule = new HRule();
> tagCloudHR.styleName = "tagCloudHR";
> tagCloudHR.width = metadataList.width;
> metadataList.addChild( tagCloudHR );
> }
> break;
> default:
> metadataText = item.name + ": " + item.value;
> textHeight = (metadataText.length/40 + 1) * 14;
> metadataHeight += textHeight;
> label.text = metadataText;
> label.width=metadataList.width;
> if ( item.name.toLowerCase() ==
> ModelLocator.getInstance().searchResultSortBy.toLowerCase() )
> {
> label.styleName = "selectedMetaDataLabel";
> }
> else
> {
> label.styleName = "metaDataLabel";
> }
> metadataList.addChild( label );
> break;
> }
> }
>
> metadataHeight += 15; // for the less button height
> return metadataHeight;
> }
>
> any suggestions on what wold be the cause or any suggestions to
> optimize this?
>
> thanks for your time
>
> Jeff
>
>  
>



-- 
"Therefore, send not to know For whom the bell tolls. It tolls for thee."

:: Josh 'G-Funk' McDonald
:: 0437 221 380 :: [EMAIL PROTECTED]

Reply via email to