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();