views:

43

answers:

2

I'm instantiating a group of RadioButton components into a Sprite and then later adding it to the display list. When the latter occurs, I can visibly see the font of the RadioButtons' labels changing from a serif to sansserif—but I have NO code to that effect anywhere. This occurs long after the components are actually instantiated, when they (via their parents) are added to the displaylist.

In Question_UI.answersContainer.answer:

answerUI = new RadioButton();
answerUI.group = rbg;
answerUI.label = text;
answerUI.tabIndex = id;
answerUI.textField.autoSize = TextFieldAutoSize.LEFT;

later...

ui.questionHolder.addChild(currentQuestion.ui);

Any ideas? I've triple-checked the obvious, but there's NO code regarding the font of the label at all. It seems to only have to do with being added to the displaylist.

A: 

Sorry to state the obvious but how would you know of any changes occurring if you don't add them to the display list?

The change from serif to sans serif reminds me of what happens when trying to access a font that's not available and the display defaults to Times.

I've never experienced anything similar but is it at all possible that your app cannot find the sans serif font when you first add the buttons , then somehow finds it... Strange indeed!

PatrickS
I am adding them to the display list via their parents, I just didn't list those parts of the code.
Virgil Disgr4ce
+1  A: 

Hm, I am assuming that you mean re-parenting the radiobuttons (that is, removing them form the sprite on the stage and adding them directly to the stage - otherwise they wouldn't be visible and you couldn't see the change).

Did you consider style inheritance? If you don't set the font used directly in the radiobutton itself, it will inherit it from its parent. So, when you re-parent it to a displayobject that has a different default font it will inherit the change.

jpop