2

i want to populate a horizontalList component from a xml file, the width value will be inside the xml file as well with all the data.

actually i have this code:

<mx:Model id="epg" source="epg.xml" /> 

<mx:Component id="customRend">
    <mx:Label text="{data.description}" width="{data.width}"/> 
</mx:Component>

<mx:HBox x="82" y="104" width="1203" height="113" verticalAlign="middle">
    <mx:HorizontalList width="100%"  dataProvider="{epg.channel.program}" 
        itemRenderer="{customRend}" horizontalScrollPolicy="off">
    </mx:HorizontalList> 
</mx:HBox>

but it sets same width for all elements in the list.

Do you know how to do this?

Thanks a lot. Br

1 Answer 1

0

Two ways to do this:

  • Set label.width = data.width on creationComplete
  • Wrap Label in Canvas

The creationComplete way (probably because an itemRenderer should be a Container?):

<mx:HorizontalList width="100%" dataProvider="{epg.channel.program}"  horizontalScrollPolicy="off">
    <mx:itemRenderer>
        <mx:Component id="customRend">
            <mx:Label text="{data.description}" creationComplete="this.width = data.width"/> 
        </mx:Component>
    </mx:itemRenderer>
</mx:HorizontalList>

... or wrapped in Canvas:

<mx:HorizontalList width="100%" dataProvider="{epg.channel.program}"  horizontalScrollPolicy="off">
    <mx:itemRenderer>
        <mx:Component id="customRend">
            <mx:Canvas horizontalScrollPolicy="off">
                <mx:Label text="{data.description}" width="{data.width}"/> 
            </mx:Canvas>
        </mx:Component>
    </mx:itemRenderer>
</mx:HorizontalList>

Hope that helps, Lance

2
  • thanks for your help. i tried this code, but still same issue. The width is always the same for all the elements, i have no hint about this :-(
    – Daniel M.
    Commented Feb 25, 2010 at 11:56
  • i have flex builder 3, what i really want to implement is something like this jaganath.files.wordpress.com/2006/12/guide.PNG, maybe there is other easier component that i can use ...
    – Daniel M.
    Commented Feb 26, 2010 at 5:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.