PDA

View Full Version : auto height adjusting textfield???


loaded
03-22-2003, 12:43 PM
if been UTFSM and browsing, but can't find a solution.

Point is I want to make a textfield rezise in height according to the lenght of text.

like for instance done in http://www.flash-tools.com/

got this but aint got a clue as to how to scale it to the text???


var myText = new Array();
myText[0] = "Just a little crappy story to test how to set a dynamic textfield height???";
myText[1] = "What about this one?";
for(i=0;i<myText.length;i++){
//vars
var myField = "text";
var myHeight = "100";
var myWidth = "100";
//length
trace(myText[i].length);
_root.createTextField(myField+i, i, 0, 0, myWidth, myHeight);
_root[myField+i].wordWrap = true;
_root[myField+i].autoSize = false;
_root[myField+i].border = true;
_root[myField+i].text = myText[i];
_root[myField+i]._x = 10;
_root[myField+i]._y = 10+(100*i);
my_tf = new TextFormat();
my_tf.font = "verdana";
_root[myField+i].setTextFormat(my_tf);
}

bluegel
03-22-2003, 01:26 PM
hey

I don't know if this will help, as I've not got Flash here to test it, but have you not tried to do it as

_root[myField+i]._height = 100; (or whatever number you want to scale it too.

if this doesn't help, then sorry.

CyanBlue
03-22-2003, 01:42 PM
loaded... Set the autosize to "left", "center" or "right", and figure out how to rearrange the _y of each text fields...

bluegel... I thought you don't have an access to the Internet during the weekend... :D Gotta go get some sleep, really... :D

boyzdynasty
03-22-2003, 08:06 PM
she's thiefing of a friends computer... *hehe*

loaded
03-22-2003, 08:30 PM
well if word rap is on, i guess you'll have to figure out when text is jumping to another line???
maybe some calcullation with 8px font?
else I can calculate it with php maybe, thats what I'm much better in, hihi....

But this should be possible somehow, but how????

anyone for some concrete answers????

CyanBlue
03-23-2003, 03:44 AM
This seems to solve the problem... I tried different font type and size within the library...
Check it out and let me know...var myText = new Array();

myText[0] = "Just a little crappy story to test how to set a dynamic textfield height???";
myText[1] = "What about this one? What about this one?";
myText[2] = "What is wrong with this one?";

my_tf = new TextFormat();
my_tf.font = "Verdana";
my_tf.bold = true;
my_tf.size = 14;

for (i = 0; i < myText.length; i++)
{
//vars
var myField = "text";
var myHeight = "100";
var myWidth = "100";
//length
this.createTextField(myField + i, i, 0, 0, myWidth, myHeight);
this[myField + i].wordWrap = true;
this[myField + i].autoSize = "left";
this[myField + i].border = true;
this[myField + i].text = myText[i];
this[myField + i].setTextFormat(my_tf);
this[myField + i]._x = 10;
this[myField + i]._y = this[myField + (i - 1)]._y + this[myField + (i - 1)]._height;
}

loaded
03-23-2003, 04:54 PM
seems to work oke so far!

Thanx a bunch