Ok I've got it centering properly however now for some reason between first text field and the dot spacer, there is a white space that increases with the amount of text in the first text field. Any way to eliminate this?
Code to this point:
var gotComp = String(DAT_Company).length > 0 ? 1 : 0;
var gotDiv = String(DAT_Division).length > 0 ? 1 : 0;
var gotAddr = String(DAT_Address).length > 0 ? 1 : 0;
var gotCity = String(DAT_City).length > 0 ? 1 : 0;
var gotState = String(DAT_State).length > 0 ? 1 : 0;
var gotZip = String(DAT_Zip).length > 0 ? 1 : 0;
var gotCnty = String(DAT_Country).length > 0 ? 1 : 0;
var CityStateZip = '';
var dotSpacing = 10;
var fldSpacing = 5;
var lineWidth = 10;
var xMax = this.regPoints.xMax
// company/division
if(gotComp){
DAT_Company_txt.text = DAT_Company;
}
if(gotDiv){
DAT_Division_txt.text = DAT_Division;
}
if(gotAddr){
DAT_Address_txt.text = DAT_Address;
}
// city, state, zip
CityStateZip = (gotCity)? DAT_City : '';
CityStateZip += (gotCity && gotState)? ', ' + DAT_State : DAT_State;
CityStateZip += (CityStateZip.length > 0)? ' ' + DAT_Zip : DAT_Zip;
CityStateZip += (CityStateZip.length > 0)? ' ' + DAT_Country : DAT_Country;
CityStateZip_txt.text = CityStateZip;
// sort fields.
var origA = new Array();
var newA = new Array();
origA[0] = DAT_Company_txt.text;
origA[1] = DAT_Division_txt.text;
origA[2] = DAT_Address_txt.text;
origA[3] = CityStateZip_txt.text;
// grab the valid values for the fields
for(i = 0; i < origA.length; i++)
{
if(String(origA[i]).length > 0){
newA.push(origA[i]);
}
}
// assign values to the fields again
DAT_Company_txt.text = newA[0];
DAT_Division_txt.text = newA[1];
DAT_Address_txt.text = newA[2];
CityStateZip_txt.text = newA[3];
// Line starting position
lineWidth = 0; // Initialize to 0
lineWidth = DAT_Company_txt.textWidth;
lineWidth += DAT_Division_txt.textWidth;
lineWidth += (fldSpacing * 2);
lineWidth += (dotSpacing * 2);
if(DAT_Company_txt.text != '' && DAT_Division_txt.text != '')
{
currentX = ((this._width - lineWidth) / 2);
dat_Company_txt._x = currentX;
textWidth = DAT_Company_txt.textWidth;
dot1_mc._x = currentX + textWidth + dotSpacing;
currentX = dot1_mc._x + fldSpacing;
dat_division_txt._x = currentX + dotSpacing;
}
// New line starting position
currentX = 0; // re initialize to 0
lineWidth = 0; // re initialize to 0
lineWidth += DAT_Address_txt.textWidth;
lineWidth += CityStateZip_txt.textWidth;
lineWidth += (fldSpacing * 2);
lineWidth += (dotSpacing * 2);
currentX = ((this._width - lineWidth) / 3);
// Text Positioning
if(DAT_Address_txt.text != '' && CityStateZip_txt.text != '')
{
DAT_Address_txt._x = currentX;
textWidth = DAT_Address_txt.textWidth;
dot2_mc._x = currentX + textWidth + dotSpacing;
currentX = dot2_mc._x + fldSpacing;
CityStateZip_txt._x = currentX;
}
|