Help with resizing textArea component : Text getting streched

Hey guys,

I am currently working on a client’s website. I need some help though.

Problem:
I have a textarea component. This textarea will have text loaded dynamically, so bascially I dont know what the maxVPosition is until runtime. I tried to resize the textarea so that the text doesn’t have to scroll, but this makes the font strech too… making it rather large. I have tried the following to counter this…


this._height += this.maxVPosition * (Number(font_size) + 10);
this.vScrollPolicy = "off";
font_size2 = font_size * (init_height/this._height);
this.setStyle("fontSize",Math.round(font_size2));

this however does not work as the font still stays huge.

Any ideas are appreciated.

Thanks
Aditya

how did you resize the textarea?
if with the transform tools, remove, put a new one, and resize with property inspector only (width & height values).

I think he’s resizing dynamically at runtime, eyez. :wink:

I personally don’t know the solution to your problem… Is there a “rows” or “cols” property associated with the component?

yeah I am resizing at runtime… as the this._height = something suggests. I have looked at various properties in the actionscript dictionary but couldn’t find any that helped me =( … I mean if I set a style, it should change right???

HELP :crying:

Is there a specific reason you are using the text area component instead of just and dynamic textfield. The component has all the properties applied to it as though the text is a picture, thus the streching, it doesn’t apply the _width/_height properties to the bounding box as a regular textfield would.

I am using a textarea because I need the CSS functionality… I didn’t think the regular textbox would support CSS (or images for that matter).

anyone? :-/

Hmm, can you dynamically create a Textarea component at runtime?

Not sure about css I’ll have to check but I know pictures are supported…

Thanks for the tip Gwing… never crossed my mind.

Flash being as awesome as it is, it does allow you to create instances of components at runtime :cool:

You just have to drop the component in your movie’s libary and do something like this:


import mx.controls.TextArea;
createClassObject(TextArea,"_message",10,{_height:200,text:"blah blah"});

kinda interesting… a lot of software is moving towards the whole import and packages deal… good stuff :smiley:

CHEERS,
Aditya

Excellent, no problem. Glad to be of help.

could also try to use the textfield.autoSize feature… :wink:
works fine