Posted By

jorisros on 05/02/10


Tagged

align TextField vertical


Versions (?)

Text vertical align


 / Published in: ActionScript 3
 

  1. //Draw background
  2. var square:Sprite = new Sprite();
  3. addChild(square);
  4. square.graphics.beginFill(0x0000FF);
  5. square.graphics.drawRect(0,0,250,250);
  6. square.graphics.endFill();
  7.  
  8.  
  9.  
  10. //Draw textarea
  11. var myTextField:TextField = new TextField();
  12.  
  13. addChild(myTextField);
  14.  
  15. myTextField.text = "some text here!\n Next line";
  16. myTextField.width = 250;
  17. myTextField.height = 250;
  18. myTextField.border = false;
  19.  
  20. var myFormat:TextFormat = new TextFormat();
  21. myFormat.color = 0xAA0000;
  22. myTextField.setTextFormat(myFormat);
  23.  
  24.  
  25. //Set the text to the middle
  26. var middle:Number = myTextField.height /2;
  27. myTextField.y = middle - myTextField.textHeight;

Report this snippet  

You need to login to post a comment.