Search This Blog

Mind freaker Stuff

Please Visit my new blog http://www.mindfreakerstuff.com for new articles related to web and mobile designing.

Sunday, November 27, 2011

Vertical Text Alignment for Dynamic Text Field Flash Action script 2

This is a simple Hack for flash Dynamic Text Field  With AS2 Where  Vertical Text Align is not supported.
Instated of setting Text Vertically  align we can position Text Field vertically Center by Y axis Position  .

Steps : Add Follwing code in on layer action

//To get Empty text field height 
blank_height  = TextField_instance._height;


//Setting Text to text field 
TextField_instance.text = "This text is vertically align";

//Adding autosize to text field  
TextField_instance.autoSize = "center";


//for Vertical Alignment
TextField_instance._y = TextField_instance._y + (blank_height  -TextField_instance._height) / 2;

Thanks,
Cheers....  :)

6 comments:

  1. Thanks for this! Works like a charm :)

    ReplyDelete
  2. You need to take in account the fact that textHeight might be smaller than the textfield height therefore the correct code for the last line is:

    TextField_instance._y = TextField_instance._y + (blank_height -TextField_instance.textHeight) / 2;

    ReplyDelete
  3. Thanks for indicating the way :)

    ReplyDelete
  4. I just wanted to say thank you for sharing such a helpful and detailed post about website design; your tips and explanations are very practical and easy to follow.
    "https://digitalvignan.com/best-website-design-company"Best Website Designing company in Warangal
    Then you've come to the right place. Digital Vignan Boost Your Online Presence with Our Expert Website Design Services. We Create User-Friendly, High-Performance Websites That Look Stunning, Function Seamlessly, and Drive Business Growth.

    ReplyDelete