Groups | Blog | Home
all groups > flash actionscript > june 2005 >

flash actionscript : getting the size of a textbox


bman979
6/7/2005 10:13:37 PM
First off I am fairly new to flash. My problem is getting the pixel width of a
autosized textbox which is part of a button. This will be part of a navigation
system which first reads the data from a xml file and then creates the
navigation bar. I can get the length of the charaters in the textbox with no
problem, but i cant seem to get the width of the textbox.

The top level buttons are set up using the var "title" to populate their text
from the xml.

Below is a sniplet of the code I am using:

for(i=0;i<no_sections;i++){
var lenStr = 0;
var sub_yval = 25;

duplicateMovieClip("navbar.clip","clip"+i,i+lenStr);
eval("navbar.clip"+i).title = root_element.childNodes.attributes.title;

//This portion gets the characters in the textbox, but is really not even
needed.
var ThisStr =
root_element.childNodes.attributes.title;
lenBox = Length(ThisStr);

eval("navbar.clip"+i)._x = xval;
eval("navbar.clip"+i).title.autoSize = "center";

//I should be able to get the width
of the textbox now that it has been populated and autosized.
//var lenStr = eval("navbar.clip"+i).nbutton.textnbutton._width;

eval("navbar.clip"+i).nbutton._width = lenStr;

Any assistence would be much appreciated. I have searched all over trying to
find a solution to this problem. Thanks.
Leonardo B. Nogueira
6/7/2005 11:13:47 PM
Hello,

I think it's simple: textBox_txt._width, after you set the property
".text" of the textField.

Make a test, ok?

I hope it helps.
Leonardo B. Nogueira

[quoted text, click to view]
AddThis Social Bookmark Button