Copy link to clipboard
Copied
I have Input Text box and the size is Width: 200 and Hight: 150. I need to align text vertically center using action script.
Please help me!
Thanks,
Jafy
Below is an example of centering. As for the XML, etc., I guess it is a different topic - for a new thread it is.
...var textContainer:Sprite = new Sprite();
var g:Graphics = textContainer.graphics;
g.beginFill(0x80FF00);
g.drawRect(0, 0, 400, 300);
g.endFill();
var format:TextFormat = new TextFormat("Arial", 20, 0x0000FF, "bold");
var textField:TextField = new TextField();
textField.autoSize = TextFieldAutoSize.LEFT;
textField.defaultTextFormat = format;
textField.text = "This is the text!\nAnd it is center
Copy link to clipboard
Copied
TextField doesn't have vertical alignment. You need to place it into another container and align it relative to this container.
Copy link to clipboard
Copied
You want to move the text field to align it with something? You can use the textHeight property of the field to get the height of the text in pixels. Divide that by 2 and you have it's center.
Copy link to clipboard
Copied
Hi Friends Thanks for the reply.
Do you have any sample for this?
And I need one more help
1. I am getting the content from XML and showing to the text box. If the content is more than the text field size then its hide the content. Please tell me how I adjust the height of the text box according to the XML content.
2. I have some XML content with HTML links and loading this to another text box. I need to highlight the corresponding content(link) when mouse over.
Please help me!
Thanks,
Jafy
Copy link to clipboard
Copied
Below is an example of centering. As for the XML, etc., I guess it is a different topic - for a new thread it is.
var textContainer:Sprite = new Sprite();
var g:Graphics = textContainer.graphics;
g.beginFill(0x80FF00);
g.drawRect(0, 0, 400, 300);
g.endFill();
var format:TextFormat = new TextFormat("Arial", 20, 0x0000FF, "bold");
var textField:TextField = new TextField();
textField.autoSize = TextFieldAutoSize.LEFT;
textField.defaultTextFormat = format;
textField.text = "This is the text!\nAnd it is centered\nall over the place";
textField.x = (textContainer.width - textField.width) * .5;
textField.y = (textContainer.height - textField.height) * .5;
textContainer.addChild(textField);
addChild(textContainer);
Copy link to clipboard
Copied
Thanks lot Andrei1, now I have posted a new one for XML.
Please help me!
Jafy
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more