JD Isaacks
JD Isaacks

Reputation: 57964

Flex: bind a label's fontSize to be half the size of another label?

Is there a way to bind a Label's fontSize to be half the fontSize of another label?

I tried this:

<mx:Label id="mytitle" text="{title}" fontSize="{(mylabel.getStyle('fontSize') as Number)/2}"/>

No luck...anyone know a way?

Thanks

Upvotes: 1

Views: 707

Answers (2)

inferis
inferis

Reputation: 1293

Your chosen method won't work because getStyle isn't bindable. You could always bind both labels to some other value (one to it unmodified and one to that value divided by 2) and change that rather than the font size on the label itself.

The existence of a good solution might depend on why you want to do this though.

Upvotes: 1

Kevin Beck
Kevin Beck

Reputation: 2390

What you tried gets called too early, so the font for "mylabel" isn't initialized yet. You could use the initialize event to do this after the UI components are filled in.

<mx:Label id="mytitle" text="{halfSize}"
          initialize="{setStyle('fontSize', mylabel.getStyle('fontSize') / 2)}"/>

Upvotes: 1

Related Questions