In a flex project that I have that is designed to scale 100% to the web window, I have a spark list. And I have a simple itemrenderer that takes the data and displays a name, and a message. Just think of it like a simple instant messenger display. The problem is that for my msg_txt
label I want to give it a width thats the width of the parent list thats holding it.
I tried turning the horizontalScrollPolicy to off, also tried width="{this.parent.parent.width}" (as well as this.parent.width) for the spark label inside the item renderer.
and in the label i tried some things like left="0" right="0" maxWidth="{this.width}" but nothing really does the trick.
How can I make this label have a max width of the list thats holding it, AND make sure it resizes if the size of the browser changes and the list size changes?
heres the list:
<s:List id="chat_content" width="100%" height="100%"
alternatingItemColors="[#EEEEEE,#E6E6E6]" contentBackgroundColor="#EEEEEE"
horizontalScrollPolicy="off" itemRenderer="renderers.ActiveChatItemRenderer">
</s:List>
heres the itemrenderer:
<?xml version="1.0" encoding="utf-8"?>
<s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark">
<fx:Script>
<![CDATA[
import mx.core.FlexGlobals;
import mx.events.FlexEvent;
import spark.components.List;
override public function set data(value:Object):void {
super.data = value;
if (data == null)
return;
if(data.systemMsg)
{
}
if(data.name)
{
name_label.text=data.name;
}
if(data.icon)
{
}
if(data.msg)
{
msg_txt.text=data.msg;
}
}
]]>
</fx:Script>
<s:states>
<s:State name="normal" />
<s:State name="hovered" />
<s:State name="selected" />
</s:states>
<s:HGroup id="container" horizontalAlign="left" verticalAlign="top" paddingTop="10" paddingBottom="10">
<s:VGroup horizontalAlign="center" verticalAlign="middle"
width="100">
<s:Label id="name_label" fontWeight="bold" text="Name: "
fontSize="18"/>
</s:VGroup>
<s:Label id="msg_txt" text="msg text here" width="{this.parent.parent.width}"/>
</s:HGroup>
</s:ItemRenderer>