SkyeBoniwell
SkyeBoniwell

Reputation: 7092

Dynamically change width of a label

I have the following 4 labels arranged on a page.

    <s:Label id="lblName" x="10" y="13" text="{data.name}"/>
    <s:Label id="lblComputer" x="10" y="37.5"  text="{data.computer}"/>
    <s:Label id="lblModel" x="45" y="37.5"  text="{data.model}"/>
    <s:Label id="lblCPU" x="43" y="63"  text="{data.cpu}"/>

I'm trying to get the layout to look like this:

lblName

lblComputer lblModel

lblCPU

It works if lblComputer is a short name, but if it has a lot of characters, then lblComputer and lblModel run together and are totally unreadable.

Is there a way to change the x-value of lblModel dynamically to "make room" for lblComputer if lblComputer happens to be really long?

Thanks

Upvotes: 0

Views: 88

Answers (1)

Barış Uşaklı
Barış Uşaklı

Reputation: 13510

You can put them in VGroup and HGroup and remove the x,y flex will handle the positioning;

<s:VGroup>
    <s:Label id="lblName"  text="{data.name}"/>
    <s:HGroup>
        <s:Label id="lblComputer"   text="{data.computer}"/>
        <s:Label id="lblModel"   text="{data.model}"/>
    </s:HGroup>
    <s:Label id="lblCPU"  text="{data.cpu}"/>
</s:VGroup>

Upvotes: 3

Related Questions