I want to align text to “right” but nothing happens. Now it’s bad looking (score count):
I want to for example “0” be on the right, and others align to this position
I want to align text to “right” but nothing happens. Now it’s bad looking (score count):
I want to for example “0” be on the right, and others align to this position
While it doesn’t solve your original problem, looking at the game I think a better solution would be to pad with 0’s, so it displays ‘00000’ instead of just ‘0’. That’d match your font and style really well I think
To do so, simply use something like this:
public function zeroPad(number: int, width: int): String
{
var ret: String = "" + number;
while(ret.length < width)
ret = "0" + ret;
return ret;
}
If you want the solution for your original problem, then could you post the code you are using to attempt to align to the right?
You should be able to specify settings with the options
argument in your Text
's constructor.
Here’s an example.
var myText:Text = new Text("Please keep right.", 100, 200, {align: "right"});
There will be larger or lower values, I set big ones for tests So I think good aligning to right will be better. Previously I added align by texts[i].align = “right”; when I added it in constructor all is the same, and when I added it one step after setting new texts’s[i].text it still not align to right.
The problem is that the text is aligned right within a Text object which is exactly the same size as the text. The align property doesn’t mean anything in that case.
You want to either set the width of the Text objects to some fixed number which is wider than the text will ever be, or set the x position to x = rightpos - text.width