Results 1 to 2 of 2

Thread: dynamic text field background

  1. #1
    Join Date
    May 2007
    Posts
    31
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default dynamic text field background

    i have data being read from an xml file. flash then displays one of the xml attributes in a dynamic text field. my dynamic text file is set to multiline.

    how do i create a background for this text that adjusts to the height of the text that is displayed? for example, i must draw an area for the dynamic text field to display up to four lines of data. i would like to create a background below this text that adjusts to how many lines of text there are. how can this be done?

    any help is much appreciated. thanks in advance!

  2. #2
    Join Date
    May 2007
    Posts
    31
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    i found the answer to my own question. first i found the properties of the TextField object which solved this problem in a non-pretty way....

    textFieldName.text = XMLvar;
    textFieldName.background = true;
    textFieldName.autosize = true;

    so this loads the xml data into the dynamic text field, gives that text field a background (default is white, but you can alter it too), and then autosizes the height. this works fine but the corners of the edges for the background are not rounded, which i think looks like crap. so i made it prettier....

    textFieldName.text = XMLvar;
    textFieldName.autosize = true;
    var textHeight:Number = textFieldName._height;
    textFieldBG._height = textHeight;

    so this loads the xml data like before, does not give the text field a background, but still autosizes it. then it creates a variable named textHeight to get the height of the text field once it has been auto-sized to the contents. then textFieldBG, a box with nice rounded corners, is sized to the same height as the text field.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •