That was an abbreviated version just so you could get the sense of what I was 
doing.  But 
yes, for step 1 of making this component I'm simply trying to get a Label to 
appear.  It will 
work fine if I use MXML and do:

/* --- MXML Renderer --- */
<?xml version="1.0" encoding="utf-8"?>
<mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml"; horizontalScrollPolicy="off">
        <mx:Label text="{data}">
                <mx:rollOverEffect>
                        <mx:Glow />
                </mx:rollOverEffect>
        </mx:Label>
</mx:HBox>
/* === MXML Renderer === */

But I'm just trying to understand what isn't working regarding my AS version.

--- In [email protected], "Joan Lafferty" <[EMAIL PROTECTED]> wrote:
>
> The code below doesn't compile for me. What are you trying to do? Just
> add extra text to each data's label?
> 
> ________________________________
> 
> From: [email protected] [mailto:[EMAIL PROTECTED] On
> Behalf Of aicfan4
> Sent: Friday, March 21, 2008 12:15 AM
> To: [email protected]
> Subject: [flexcoders] Custom ItemRenderer in HorizontalList
> 
> 
> 
> I'm trying to display a horizontal list of words in an AIR application.
> I'm creating a custom 
> component for the ItemRenderer, and then am setting the HorizontalList's
> dataProvider to 
> an array of strings.
> 
> I can see the proper # of items are being added to the HorizontalList
> (the rollover mouse 
> state is appearing for the appropriate number of items), but no text is
> displayed in the 
> list. I'm tracing within the component and it's setting the text for
> each item properly, so 
> I'm stumped. Anyone have any ideas?
> 
> /* --- ListContainer.mxml --- */
> 
> <mx:Canvas ...>
> <mx:Script>
> <![CDATA[
> import mx.collections.ArrayCollection;
> [Bindable] private words:ArrayCollection = new ArrayCollection(["bug",
> "show", "me", 
> "the", "text"]);
> ]]>
> </mx:Script>
> 
> <mx:HorizontalList width="100%" dataProvider="{words}"
> itemRenderer="MyRenderer" 
> />
> </mx:Canvas>
> 
> /* === ListContainer.mxml === */
> 
> /* --- MyRenderer.as --- */
> 
> import mx.controls.Label;
> import mx.controls.listClasses.IListItemRenderer;
> import mx.core.IDataRenderer;
> import mx.core.UIComponent;
> 
> public class MyRenderer extends UIComponent implements IDataRenderer, 
> IListItemRenderer {
> protected var wordLabel:Label;
> 
> private var _word:String;
> private var _wordChanged:Boolean;
> 
> public function MyRenderer() {
> super();
> _word = "";
> _wordChanged = false;
> }
> 
> override protected function commitProperties():void {
> super.commitProperties();
> if(_wordChanged) {
> _wordChanged = false;
> wordLabel.text = _word;
> trace("wordLabel being set: " + wordLabel.text + " and is visible: " +
> wordLabel.visible);
> invalidateSize();
> }
> }
> 
> override protected function createChildren():void {
> super.createChildren();
> if(!wordLabel) {
> wordLabel = new Label();
> addChild(wordLabel);
> }
> }
> 
> override protected function measure():void {
> super.measure();
> 
> measuredWidth = wordLabel.getExplicitOrMeasuredWidth();
> measuredHeight = wordLabel.getExplicitOrMeasuredHeight();
> }
> 
> public function get data():Object {
> return _word;
> }
> 
> public function set data(value:Object) {
> if(value is String) {
> _word = String(value);
> _wordChanged = true;
> invalidateProperties();
> invalidateDisplayList();
> }
> }
> 
> }
> /* === MyRenderer.as === */
>



Reply via email to