我有一个文本字段数组,因为数组元素具有不同的宽度大小。我想将它作为没有空格的一行添加到舞台上。那么..如何设置 x 轴?
这是代码:
var _objects:Array = new Array();
var rowCount:uint = 114;
for (var o:uint = 0; o<114; o++)
{
var label_txt:TextField = drawTxt();
_objects.push(label_txt);
label_txt.y = 10
label_txt.x = (o % rowCount) * (_objects[o].width);// this code gives me 100 px on x for each element.
addChild(label_txt);
}
更多细节
文本域:
function drawTxt():TextField
{
var label_txt:TextField = new TextField();
label_txt.border = true;
label_txt.antiAliasType = AntiAliasType.ADVANCED;
label_txt.selectable = false;
label_txt.multiline = false;
label_txt.defaultTextFormat = myFormatBold;
return label_txt;
}
文本数据(xml):
function arrayzeLabelsXML():void
{
for (var i:int = 0; i < xmlLabelsData.item.length(); i++)
{
attributeLabelsContent.push(xmlLabelsData.item[i].@item);
translateContent.push(xmlLabelsData.item[i].@translate);
nodeLabelsContent.push(xmlLabelsData.item[i]);
nodeContent.push(xmlLabelsData.translate[i]);
_objects[i].text = nodeLabelsContent[i];
_objects[i].width = _objects[i].textWidth + 20;
_objects[i].addEventListener(MouseEvent.CLICK,clickHandler);
}
}
谢谢