Copy link to clipboard
Copied
Ok, I'm new to ActionScript, but I can adapt quite easily, so I have started a project, it loads a XML file with some data, after it is loaded it adds a bar for every node it can find in the xml file. The bar is converted to a symbol and acts as a button. Now I want to add a label as a child to the bar. And there comes the problem, when I add the label to the bar, and compile the .fla the label is flickering all the time. I also pull some data from each node to add a text to the label, but its not beeing displayed either. Could someone please explain me, why the label is flickering and the bar is not?
Here is the code so far for adding the bars and the labels
var btn:Standing; // Symbol
var lbl:XmlLabel;
for (var i:int = 0; i < len; i++) {
btn = new Standing();
btn.x = 287;
btn.y = 190 + i * 46;
addChild(btn);
btn.name = "btn" + i;
btn.buttonMode = true;
btn.addEventListener(MouseEvent.CLICK, onButtonClick);
var teamElement:XML = teamElements;
var nameString:String = teamElement.@name;
var winString:String = teamElement.@wins;
var lossesString:String = teamElement.@losses;
var id:int = parseInt(nameString);
for (var o:int = 0; o < 4; o++) {
lbl = new XmlLabel();
lbl.x = 20 + o * 70;
lbl.y = 10;
lbl.text = nameString.toString();
btn.addChild(lbl);
lbl.name = "lbl" + i + o;
}
Thanks for the help
what is XmlLabel? a textfield? a movieclip? something else?
Copy link to clipboard
Copied
what is XmlLabel? a textfield? a movieclip? something else?
Copy link to clipboard
Copied
XmlLabel is a MovieClip, I have dragged it from the components panel to my stage and deleted it and edited its properties in the library panel
EDIT: I have marked your answer as correct, because you hinted me to the correct solution, I had to make the Label's base class fl.controls.Label and not the standard
flash.display.MovieClip
Thanks for the hint
Copy link to clipboard
Copied
you're welcome.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now