View Full Version : The height of a dynamically created textfield
Ruben
06-03-2004, 10:17 AM
Hi, hello and everything else...
If I'd have a variable with some html-text and I'd want to put it into a textfield created by actionscript, how can I find out what the height of the textfield should be?
I was thinking of roughly counting the text with a for-loop, like increasing some variable a lot when a "<br>" is detected and ignoring other brackets and stuff, but I figured there might be an easier way to achieve this...right??
Thanks for all your time - Ruben
Ruben
06-04-2004, 05:46 AM
...anyone???
:confused: - Ruben
Mortimer Jazz
06-12-2004, 03:28 PM
Hey Ruben.
The textbox can be set to resize automatically according to the text, rather than the other way around.
createTextField("my_txt", 1, 0, 0, 200, 20);
with (my_txt) {
border = true;
borderColor = 0x000000;
multiline = true;
wordWrap = true;
autoSize = "left";
text = "Here is a whole bunch of text that won't fit in the field";
}
trace(my_txt._height);
hi mortimer jazz,
thanx for the above script, but i still have aproblem with it...
as long as i don´t use embedFonts = true; the script works fine, but i use some pixel fonts and NEED TO EMBED them... any idea... :(
cobo
Ruben
06-18-2004, 04:48 AM
What if you'd set the mask through actionscript?? Like converting the shape that masks your clip to a movieclip, instancenaming it "maskClip" and putting this script inside of the clip you want masked:
this.setMask(maskClip);
Does that work? Just a wild guess though :p - Ruben
the problem is not the masking, it´s the font itself...
the first image shows the problem...
the second one shows how it SHOULD look like..
Ruben
06-18-2004, 05:32 AM
Hm...seems like your not really doing stuff with the htmlbox that you can't do with normal textboxes...or am I sadly mistaken?
So maybe you could replace all of the "<br>" by "\n" and just use normal textfields instead of html embedded ones...
Is that an option? - Ruben
i tried to drop the html = true; but the problem is still the myField.embedFonts = true; line
I don´t know what to do... :confused:
cobo
petefs
06-18-2004, 05:54 AM
pixelfonts require the TextField to be aliased. If you develop for player 7 you can toggle the textfield's alias switch even if the font is embedded. Unfortunately there is no code analog (at least none documented), so if you are generating your textfields dynamically you're out of luck. If you can avoid generating your textfields dynamically you can use this switch to take care of your problem.
On a side-note, player 7 SHOULD alias text below a certain point size. It's part of their 'better small-font readability' feature. I could be wrong WRT dynamically generated textfields however.
), so if you are generating your textfields dynamically you're out of luck.
well i get my txt out of a database -> load it into flash -> want it to be a pixelfont and scrollable...
is there no way at all?
a disenchanted flasher... :(
Ruben
06-18-2004, 07:07 AM
Dunno if the autosize property can be applied to a not as-generated textfield...
:confused: - Ruben
Mortimer Jazz
06-18-2004, 07:15 AM
I believe I worked out a way around this (font-embedding in dynamic run-time textboxes).
Give me ten minutes and I will check by knocking a fla together.
Mortimer Jazz
06-18-2004, 08:08 AM
Sorry for the delay.
Please test this (view the HTML/SWF before running the Fla) and you should see a nice size 8 "FFF Aquarius" pixel font. Let me know if you have any problems. I commented the fla for you too.
Cheers,
Neil
Stimpson
06-19-2004, 08:53 AM
Ok, haven't read the whole thread... DOH! But couldn't you just use automatic resizing without embedding, get the correct height, embed the fonts, and then set the height of the textfield :).
Hmmm, Mortimer Jazz posted something already... ignore me :).
Mortimer Jazz
06-19-2004, 02:45 PM
Yeah the topic has strayed a little :]
Wouldn't mind someone confirming that my attachment works (and that I haven't made some silly mistake) if they have time.
Ruben
06-20-2004, 02:36 PM
Well, I've had a look at the swf yesterday and it seemed to be doing fine...though the best test would be cobo integrating your trick into his fla, right?
:) - Ruben
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.