TextFormat parameters not applying until 2nd call
I'm finding a sample label I add doesn't apply the assigned text formatting until the 2nd time it's called. The variables in this function aren't used anywhere else. I'm working on drawing a pie chart upon arrival at frame2. Before I get to the actual pie logic, I'm just testing the basic drawing parameters. The variables it uses are defined at the top of the AS3 for frame2:
var pieChart:Shape = new Shape;
var pieLabel_1:TextField = new TextField()
var tf:TextFormat = new TextFormat();
Then used in this stub function:
function draw_pie():void{
// Pie chart elements
trace("draw pie chart");
// Pie graphic logic TBD, place holder graphic
pieChart.graphics.beginFill(0xFFaaFF); // fill color
pieChart.alpha=.7; // temp alpha to see position relative to other graphics
pieChart.graphics.drawCircle(1660,545, 140); // (x upper left, y upper left, radius)
pieChart.graphics.endFill(); // end the fill
addChild(pieChart); // adds the circle to the stage
// label parameters
tf.font = "Arial";
tf.size = 56;
tf.color = 0x00FF00;
pieLabel_1.setTextFormat(tf);
pieLabel_1.text = "Label 1";
pieLabel_1.x = 1660;
pieLabel_1.y = 545;
addChild(pieLabel_1);
}
But the test label is intially drawn with the default format until an interaction on that same frame causes it to update, (at this point, just redraw). Is a flush or other refresh function needed before the setTextFormat function takes effect? The text format assignments in other components take effect without a refresh. Is an added action needed before a child can be added to the stage with the assigned format?
