0

Adobe Animate CC
Javascript

Does anyone know how to vertically center text in a dynamic text box in Adobe Animate when using Javascript? Not to be confused with vertically centering text in HTML with CSS.

This doesn't work:

myTextBox.style.display="table-cell";
myTextBox.style.verticalAlign="middle";

1 Answers1

0

Assuming that your textbox is on the stage (not embedded in a MovieClip), you can vertically align a textbox by updating its y position. To do so, you must get a reference to the stage's height and divide this value by 2.

For example:

this.stop();

this.myTextBox.y = (stage.canvas.height) / 2;
Chris
  • 4,186
  • 11
  • 44
  • 79
dommiDom
  • 11
  • 3