I moved this post to one of the help forums, because you'll get help there. The Boardroom (where you originally posted) is reserved for discussing topics about business and the industry.
Make a textfield and give it the intancename 'mytext'. Select whatever font from which you want to get the character widths.
In the characters menu select 'Embed font outlines for: All characters'.
Code:
fontWidths = new Array();
//this will contain an array of the width of each character
myText.autoSize = "left";
textfieldmargin = 4 // 2 pixels margin on both sides off the character
for(i=0;i<255;i++){
myText.text = String.fromCharCode(i)
chrWidth = myText._width;
// if the textfield has margins use this code
// chrWidth-= textfieldmargin;
fontWidths.push(chrWidth);
}
trace(fontWidths);
I notice the above example uses "myText.autoSize"... that's an MX only function. I'm using Flash 5 (and hopefully publishing to Flash 4 .swf)... Does anyone know a way to do this in earlier versions of Flash?
found an fla that has simalar acion script in but still can get it to work. I am trying to create a dynamic text scroller and have tried lots of variations to get the width of the latest char but not working
Code:
duplicateMovieClip("char", "char" add i, i);
set("char" add i add "/letter:char", substring(text, i, 1));
thewidth = (["char"+i])._width;
trace("thewidth="+thewidth);
why the heck are you using f4 syntax. My code works perfectly the way it is
Are you sure youre working with the textfields instance name instead of the variable name?
*btw - when using flash4 or flash5 instead of measuring the hard way - you could off course use the function in flash6 and paste the traced values into your array*