all groups > flash actionscript > january 2006 >
You're in the

flash actionscript

group:

TextField maxhscroll bug?


TextField maxhscroll bug? jpeterse77
1/8/2006 8:11:52 PM
flash actionscript:
I decided to give Flash a try, and figured I would make a simple marguee style
scrolling text. In the process I have run into some strange behaviour of the
maxhscroll property of the textField control.
It seams that if you assign a textFormat to the textField, and then change the
text in the textField, maxhscroll is reset. This does not appear, if you do not
assign a textFormat.
From the sample code below, I get the following output:

maxhscroll before font change: 170; real text width: 266
maxhscroll after: 468; real text width: 566.35
maxhscroll after text update: 0; real text width: 572.5
maxhscroll textFormat reset: 9450; real text width: 572.5

Have anyone else encountered this? Is there a workaround to get a more
reliable result?

Best Regards
Jan Petersen

******** Sample Code **********
my_fmt = new TextFormat();
my_fmt.font = "Verdana";
my_fmt.size = 18;
my_fmt.bold = true;
my_fmt.italic = true;
this.createTextField("myTextField", this.getNextHighestDepth(), 0, 0, 100, 32);
myTextField.type = "dynamic";
myTextField.text = "Lorem ipsum dolor sit amet, consectetur adipisicing elit";
trace("maxhscroll before font change: "+myTextField.maxhscroll + "; real text
width: "+ myTextField.textWidth);
myTextField.setTextFormat(my_fmt);
myTextField.embedFonts = true;
trace("maxhscroll after: " + myTextField.maxhscroll + "; real text width: " +
my_fmt.getTextExtent(myTextField.text).textFieldWi dth);

myTextField.text += " ";
trace("maxhscroll after text update: " + myTextField.maxhscroll + "; real text
width: " + my_fmt.getTextExtent(myTextField.text).textFieldWi dth);

myTextField.setTextFormat(my_fmt);
trace("maxhscroll textFormat reset: " + myTextField.maxhscroll + "; real text
width: " + my_fmt.getTextExtent(myTextField.text).textFieldWi dth);

stop();
Re: TextField maxhscroll bug? bitboyroy
2/8/2006 1:11:59 PM
The weird thing is that people doesn't seem to care that for example the
UIScrollBar get's messed upp when scrolling horizontally.

Say I have a textfield 600px wide. type a couple characters so the "textWidth"
reaches ~450px. Now the scrollbar component that looks for hscroll get's messed
up. It thinks the content is much much wider and then enables the horizontal
scrollbar that should display until we have content > 600px....

macro/adobe? pleasE?!


Re: TextField maxhscroll bug? bitboyroy
2/8/2006 6:16:59 PM
I've done some more testing and it looks like the hscroll value is scaled 20x
compared to it's "real" value.

This makes for example the left/right arrow-buttons on a horizontal scrollbar
to just make increments of .05px per click.

Tested switching from embedded fonts to "device fonts". This makes the hscroll
value 1:1px. Switching back to embedded fonts (regardless setting, flash 7, 8,
etc) increasing the hscroll value with 1 will only move the text something like
~.05px...



AddThis Social Bookmark Button