Niels
Niels

Reputation: 1330

Why does my Label not have a textAlign property?

I create a spark.components.Label, and I want to change the text alignment. The api states it has a property textAlign, but I get this error. What am I doing wrong?

import spark.components.Label;
var mylabel:Label = new Label();
mylabel.textAlign = "right";

Error: Access of possibly undefined property textAlign through a reference with static type spark.components:Label.

Upvotes: 0

Views: 1804

Answers (1)

RIAstar
RIAstar

Reputation: 11912

The API states that Label has a style called textAlign, not a property.

If you wish to assign a style through ActionScript, you can do so like this:

myLabel.setStyle('textAlign', 'right');

See IStyleClient#setStyle

Upvotes: 7

Related Questions