I am attempting to create some sort of information sheet that contains some rows of texts, dynamically loaded from an xml file. I don’t have much experience with Action Script, but I’ve been programming in various languages for many years.
var properties = myXML.firstChild.childNodes;
var propFormat:TextFormat = new TextFormat();
var valueFormat:TextFormat = new TextFormat();
propFormat.bold = true;
propFormat.size = 10;
valueFormat.size = 10;
valueFormat.color = 0x0000ff;
valueFormat.italic = true;
_root.myInfo_mc._height = properties.length * 15;
for(var i = 0; i < properties.length; i++){
var propTxt:TextField = _root.myInfo_mc.createTextField("prop" + i, i*2, 2, i*15, 200, 13);
var valueTxt:TextField = _root.myInfo_mc.createTextField("value" + i, i*2 + 1, 85, i*15, 200, 13);
propTxt.text = properties*.attributes.name + ": ";
valueTxt.text = properties*.attributes.value;
propTxt.autoSize = false;
valueTxt.autoSize = false;
propTxt.setTextFormat(propFormat);
valueTxt.setTextFormat(valueFormat);
}
The code is straightforward, i have one box called myInfo_mc, which is the parent.
I change its height depending on how many lines the xml file has and then I iterate through the xml properties, creating texts that I position vertically.
I am at a point where it drives me insane, because the longer the xml is, the bigger the text becomes.
If I do _root.createTextField(“prop” + i, i2, 2, i15, 200, 13) the texts will have the specified size, but I do not want a ton of texts just floating around, as it would complicate hiding/moving around the information.
Any hint would be appreciated.