In the flash IDE I have the following code. t1obj is an object with some font-related properties:
var title1 = new Paragraph(t1obj);
addChild(title1);
trace("title1.HEIGHT = " + title1.HEIGHT);
My Paragraph class assigns an integer value to its public var HEIGHT by calling a function, but apparently that takes a little while because my trace always returns 0.
If I add this:
stage.addEventListener(Event.ENTER_FRAME, getHEIGHT);
function getHEIGHT(e:Event):void {
if (title1.HEIGHT > 0) {
stage.removeEventListener(Event.ENTER_FRAME, foobar);
trace("title1.HEIGHT = " + title1.HEIGHT);
}
}
…my trace gives me the correct number.
But I’m thinking there’s a much more elegant way to wait for HEIGHT to get its value before firing the trace. What would that be??