You need to pass an implementation of the data provider interface or an array as the dataProvider for the list component.  I think this might be your problem, plus you're also setting the data provider to a single object and the parent node of the object(s) you actually want to use. 
 
Try setting your dataProvider on the list to something like this:
 
    dataProvider="{mx.utils.ArrayUtil.toArray(myTaxonomies.taxonomies.taxonomy)}"
 
p.s. :  the signature of the setValue function should actually look like this:
 
    setValue( str:String, item:object, sel:String ):Void
 
but this very rarely causes any problems and since you're not using the parameter you shouldn't notice anything wrong.  The boolean as the third paramter was a bug in the documentation. 

--
Ronald Kinion
253-205-3000 x5162
[EMAIL PROTECTED]


 


From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Cliff Meyers
Sent: Monday, June 20, 2005 7:05 AM
To: [email protected]
Subject: [flexcoders] custom renderer for list

I'm having some problems getting a custom renderer to work for a List.
All I'd like to show for each item are mx:Image and mx:Label tags.
However I'm having some problems getting it to work...

First off I'm not sure if a rowRenderer or cellRenderer is appropriate
here.  The documentation seems to indicate that a rowRenderer is only
necessary if a different "template" needs to be used from row to row.
This isn't the case in this situation since each item in the list just
needs an image and accompanying label.

Here is the code for my renderer:

<?xml version="1.0" encoding="utf-8"?>
<mx:HBox xmlns:mx="http://www.macromedia.com/2003/mxml">
      <mx:Script>
            <![CDATA[
                  [Embed(source="images/taxonomy/legal.png")]
                  var appSymbol:String;
                 
                  function setValue( str:String, item:Object, sel:Boolean ) : Void
                  {
                        myLabel.text = item.name;
                        myImage.source = appSymbol;
                  }
            ]]>
      </mx:Script>
      <mx:Image id="myImage" />
      <mx:Label id="myLabel" />
</mx:HBox>

and here is the invoking page:

<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.macromedia.com/2003/mxml">
      <mx:Model id="myTaxonomies" source="faketaxonomy.xml" />
     
      <mx:Label text="Select a category to filter the application list." />
     
      <mx:List
            id="categoryFilter"
            multipleSelection="true"
            rowCount="4"
            dataProvider="{myTaxonomies.taxonomies}"
            rowRenderer="components.categoryFilterRowRenderer" />
</mx:VBox>

When I invoke it as a rowRenderer, the images appear but the text
doesn't.  When I invoke it as a cellRenderer, the list is blank.
Lastly here is the content of my XML file:

<?xml version="1.0" encoding="utf-8"?>
<taxonomies>
      <taxonomy name="Legal" icon="legal.png" />           
</taxonomies>

Any help that anyone could pass along would be greatly appreciated.  Thanks! :)


-Cliff


Yahoo! Groups Links

Reply via email to