-
getTextExtent() returning incorrect value
I'm trying to determine the width of a string that will change dynamically.
// create LoadVars object
myLoadVar = new LoadVars();
myLoadVar.load("ticker.txt");
myLoadVar.onLoad = function (success){
if (success == true) {
newsbox.autoSize="left";
txtvar=myLoadVar.texty;
}
}
//get length of string
my_str = myLoadVar.texty;
my_fmt = newsbox.getTextFormat();
metrics = my_fmt.getTextExtent(my_str);
newslength = metrics.textFieldWidth;
trace(newslength);
This codes seems to find the width of my dynamic text box(called newsbox), but it returns the length of the dynamic string's placeholder text UNLESS i let the movie run again without stopping. Then it will return the correct length of the text I set from the file. I tried to directly set string to lookup from the LoadVar(that is the my_str variable) but it returns undefined. Any ideas seriously appreciated!
will.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|