A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: dynamically size a text box

  1. #1
    the usual
    Join Date
    Jul 2000
    Posts
    1,482
    lets say i have have an array of quotes that all differ in length, the first of which has 10 charecters, the second 70 characters and the third 300 characters

    i want to create three seperate text fields to display the text, all the text boxes need to be 100 pixels wide and the height of the textbox depends on the number of characters it needs to display

    basically i want to know how you adjust the height of the textfield to show all of the text/characters

    -----
    cheers



  2. #2
    Senior Member chi-styler's Avatar
    Join Date
    Jul 2001
    Location
    Bristol, UK
    Posts
    1,237
    Well, when I draw my text box on I would make it as big as I'd want it heightwise, then make sure it 100 pixels across, and just make sure you select multiline from the line type, and it should do the rest itself, as any unused space in the box will just be invisible.

    But that's me, maybe you have some complications in your movie

    C-S

  3. #3
    the usual
    Join Date
    Jul 2000
    Posts
    1,482
    problem solved -

    chi-styler (i'm not new to flash - that would not work in this case as i'm making everything dynamically therefore when i apply it to a movieclip it will return a wrong heght value, and as i'm parsing xml feeds i the length of text will vary

    anyway looked into help i just found out that you can use myTextField.autoresize= "center"

  4. #4
    Senior Member chi-styler's Avatar
    Join Date
    Jul 2001
    Location
    Bristol, UK
    Posts
    1,237
    Well, there ya go, maybe if you said you were all dynamic... oops, should have been able to tell by your no. of posts...

    Another problem solved! ..Ahem...

  5. #5
    Member
    Join Date
    Sep 2001
    Location
    Málaga, Spain
    Posts
    98
    hi there,
    could u please let me know how u actually managed to resize the textfield dynamically because i had read the help on this and assumed that the autoresize="center" was for alignment purposes.
    plus i've actually tried to do it and it doesn't work for me.
    please let me know how u do it. thank u




  6. #6
    Senior Member chi-styler's Avatar
    Join Date
    Jul 2001
    Location
    Bristol, UK
    Posts
    1,237
    Well, the Gospel says

    'If the value of autosize is "center", the text field auto-sizes, but the horizontal center of the text field stays anchored at the text field's original horizontal center position. The bottom side still expands to fit all contained text.'

    So that just keeps the width the same, and alters the height to fit the text. There are other values it can take to alter thing the other way around...
    Depends what you're trying to do

  7. #7
    the usual
    Join Date
    Jul 2000
    Posts
    1,482
    marinacb

    Code:
    _root.createEmptyMovieClip("holder",1)
    holder.createTextField("mytext",1,100,100,300,20);
    holder.mytext.multiline = true;
    holder.mytext.wordWrap = true;
    holder.mytext.text = "testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing testing";
    trace("height before autosize :" + holder._height)
    holder.mytext.autosize="center"
    trace("height after autosize :" + holder._height)

  8. #8
    Member
    Join Date
    Sep 2001
    Location
    Málaga, Spain
    Posts
    98
    thank u very much.
    that works and it will be very useful because i don't know the textfield object much.
    it's nice to have posts like that where u learn something... and that is being rare lately ...

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center